secretive/SecretKit/Secret.swift

24 lines
544 B
Swift
Raw Normal View History

2020-02-19 04:52:00 +00:00
public protocol Secret: Identifiable, Hashable {
2020-03-04 07:14:38 +00:00
var name: String { get }
var algorithm: Algorithm { get }
var keySize: Int { get }
2020-03-04 07:14:38 +00:00
var publicKey: Data { get }
2020-02-19 04:52:00 +00:00
}
public enum Algorithm {
case ellipticCurve, rsa
public init(secAttr: NSNumber) {
let secAttrString = secAttr.stringValue as CFString
switch secAttrString {
case kSecAttrKeyTypeEC:
self = .ellipticCurve
case kSecAttrKeyTypeRSA:
self = .rsa
default:
fatalError()
}
}
}