apple / swift-asn1

An implementation of ASN.1 for Swift
https://swiftpackageindex.com/apple/swift-asn1/main/documentation/swiftasn1
Apache License 2.0
137 stars 27 forks source link

Access structs defined in package from the outside. #60

Closed yura-eog closed 2 months ago

yura-eog commented 3 months ago

I am trying to derive a private key using this package. RFC 5208 - PrivateKeyInfo

I am following the tests and have the following code:

let buffer = Array(base)

let result = try DER.parse(buffer)
let pkey = try PKCS8PrivateKey(derEncoded: result)

however, PKCS8PrivateKey is internal and I cannot use it.

https://github.com/apple/swift-asn1/blob/544ffa8eaec503c040ad979b2dbb7a67c39cac61/Tests/SwiftASN1Tests/ASN1Tests.swift#L201

What do you recommend?

Thanks

yura-eog commented 3 months ago

I see people are forking this to change scope to public

https://github.com/ekscrypto/swift-asn1/commit/d5beb46e86ca7bf165d0a66969cfa2d5afc3b896

dnadoba commented 3 months ago

The linked commit points to PEMDocument and that is already public. swift-certificates can parse private keys: https://swiftpackageindex.com/apple/swift-certificates/1.5.0/documentation/x509/certificate/privatekey

yura-eog commented 2 months ago

The linked commit points to PEMDocument and that is already public. swift-certificates can parse private keys: https://swiftpackageindex.com/apple/swift-certificates/1.5.0/documentation/x509/certificate/privatekey

Thank you 👍