File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -19,10 +19,10 @@ public enum Algorithm: CustomStringConvertible {
19
19
case hs512( Data )
20
20
21
21
/// RSA using SHA-256 hash algorithm
22
- case rs256( PrivateKey )
22
+ case rs256( Data )
23
23
24
24
// RSA using SHA-512 hash algorithm
25
- case rs512( PrivateKey )
25
+ case rs512( Data )
26
26
27
27
public var description : String {
28
28
switch self {
@@ -56,7 +56,10 @@ public enum Algorithm: CustomStringConvertible {
56
56
return base64encode ( Data ( bytes: result) )
57
57
}
58
58
59
- func signRSA( _ privateKey: PrivateKey , digestType: Signature . DigestType ) throws -> String {
59
+ func signRS( _ key: Data , digestType: Signature . DigestType ) throws -> String {
60
+
61
+ let keyString = String . init ( data: key, encoding: . utf8)
62
+ let privateKey = try PrivateKey ( pemEncoded: keyString)
60
63
61
64
let clear = try ClearMessage ( string: message, using: . utf8)
62
65
@@ -80,8 +83,11 @@ public enum Algorithm: CustomStringConvertible {
80
83
case . hs512( let key) :
81
84
return signHS ( key, variant: . sha512)
82
85
83
- case . rsa256( let privateKey) :
84
- return try signRSA ( privateKey, digestType: . sha256)
86
+ case . rs256( let key) :
87
+ return try signRS ( privateKey, digestType: . sha256)
88
+
89
+ case . rs512( let key) :
90
+ return try signRS ( privateKey, digestType: . sha512)
85
91
86
92
}
87
93
}
You can’t perform that action at this time.
0 commit comments