|
@@ -37,15 +37,6 @@ internal protocol DERDecodable {
|
|
init(rawRepresentation: Data) throws
|
|
init(rawRepresentation: Data) throws
|
|
}
|
|
}
|
|
|
|
|
|
-extension DERDecodable {
|
|
|
|
- public init(rawRepresentation raw: Data) throws {
|
|
|
|
- /// The default implementation that makes the original internal initializer publicly available
|
|
|
|
- do { try self.init(privateDER: raw.bytes) } catch {
|
|
|
|
- try self.init(publicDER: raw.bytes)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
/// Conform to this protocol if your type can be described in an ASN1 DER representation
|
|
/// Conform to this protocol if your type can be described in an ASN1 DER representation
|
|
internal protocol DEREncodable {
|
|
internal protocol DEREncodable {
|
|
/// Returns the DER encoded representation of the Public Key
|
|
/// Returns the DER encoded representation of the Public Key
|
|
@@ -64,20 +55,6 @@ internal protocol DEREncodable {
|
|
func publicKeyExternalRepresentation() throws -> Data
|
|
func publicKeyExternalRepresentation() throws -> Data
|
|
}
|
|
}
|
|
|
|
|
|
-extension DEREncodable {
|
|
|
|
- public func externalRepresentation() throws -> Data {
|
|
|
|
- // The default implementation that makes the original internal function publicly available
|
|
|
|
- do { return try Data(self.privateKeyDER()) } catch {
|
|
|
|
- return try Data(self.publicKeyDER())
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public func publicKeyExternalRepresentation() throws -> Data {
|
|
|
|
- // The default implementation that makes the original internal function publicly available
|
|
|
|
- try Data(self.publicKeyDER())
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
struct DER {
|
|
struct DER {
|
|
internal enum Error: Swift.Error {
|
|
internal enum Error: Swift.Error {
|
|
/// We were provided invalid DER data
|
|
/// We were provided invalid DER data
|