mirror of
https://github.com/apple/swift-crypto
synced 2026-11-26 04:47:49 +00:00
Use SecKeyGetBlockSize instead of kSecAttrKeySizeInBits (#198)
This commit is contained in:
1 parent
710deacf79
commit
953b34a601
2 files changed
+6
-8
No files matched your search
@@ -54,7 +54,7 @@ extension _RSA.Signing {
|
||||
public init(pemRepresentation: String) throws {
|
||||
self.backing = try BackingPublicKey(pemRepresentation: pemRepresentation)
|
||||
|
||||
if self.keySizeInBits < 1024 || self.keySizeInBits % 8 != 0 {
|
||||
guard self.keySizeInBits >= 1024 else {
|
||||
throw CryptoKitError.incorrectParameterSize
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,7 @@ extension _RSA.Signing {
|
||||
public init<Bytes: DataProtocol>(derRepresentation: Bytes) throws {
|
||||
self.backing = try BackingPublicKey(derRepresentation: derRepresentation)
|
||||
|
||||
if self.keySizeInBits < 1024 || self.keySizeInBits % 8 != 0 {
|
||||
guard self.keySizeInBits >= 1024 else {
|
||||
throw CryptoKitError.incorrectParameterSize
|
||||
}
|
||||
}
|
||||
@@ -108,7 +108,7 @@ extension _RSA.Signing {
|
||||
public init(pemRepresentation: String) throws {
|
||||
self.backing = try BackingPrivateKey(pemRepresentation: pemRepresentation)
|
||||
|
||||
if self.keySizeInBits < 1024 || self.keySizeInBits % 8 != 0 {
|
||||
guard self.keySizeInBits >= 1024 else {
|
||||
throw CryptoKitError.incorrectParameterSize
|
||||
}
|
||||
}
|
||||
@@ -120,7 +120,7 @@ extension _RSA.Signing {
|
||||
public init<Bytes: DataProtocol>(derRepresentation: Bytes) throws {
|
||||
self.backing = try BackingPrivateKey(derRepresentation: derRepresentation)
|
||||
|
||||
if self.keySizeInBits < 1024 || self.keySizeInBits % 8 != 0 {
|
||||
guard self.keySizeInBits >= 1024 else {
|
||||
throw CryptoKitError.incorrectParameterSize
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,8 +61,7 @@ internal struct SecurityRSAPublicKey {
|
||||
}
|
||||
|
||||
var keySizeInBits: Int {
|
||||
let attributes = SecKeyCopyAttributes(self.backing)! as NSDictionary
|
||||
return (attributes[kSecAttrKeySizeInBits]! as! NSNumber).intValue
|
||||
SecKeyGetBlockSize(self.backing) * 8
|
||||
}
|
||||
|
||||
fileprivate init(_ backing: SecKey) {
|
||||
@@ -146,8 +145,7 @@ internal struct SecurityRSAPrivateKey {
|
||||
}
|
||||
|
||||
var keySizeInBits: Int {
|
||||
let attributes = SecKeyCopyAttributes(self.backing)! as NSDictionary
|
||||
return (attributes[kSecAttrKeySizeInBits]! as! NSNumber).intValue
|
||||
SecKeyGetBlockSize(self.backing) * 8
|
||||
}
|
||||
|
||||
var publicKey: SecurityRSAPublicKey {
|
||||
|
||||
Reference in new issue
Block a user