agens-no / EllipticCurveKeyPair

Sign, verify, encrypt and decrypt using the Secure Enclave
Other
709 stars 115 forks source link

Deprecation Warnings and Making export() Method of PublicKey Public #60

Open pheckenlWork opened 3 years ago

pheckenlWork commented 3 years ago

First, THANK YOU for developing this library. We used it to develop a VPN solution for our company.

While working with EllipticCurveKeyPair.swift, We noticed that there are several places where the code now generates deprecation warnings. Also, the export() method of the PublicKey class is marked private. For our application, I needed to export the public key to generate a CSR. I can't think of a reason why this method should be private.

I would be happy to provide a PR for these issues. I thought it would be more friendly to start with an issue (instead of doing a drive by PR).

hfossli-agens commented 3 years ago

I guess main branch and develop is a bit stale. I have been working on a new api https://github.com/agens-no/EllipticCurveKeyPair/blob/renewed-api/Sources/EllipticCurveKeyPair.swift, but haven't finished it entirely.

A PR for your pressing needs would be perfect start.

pheckenlWork commented 3 years ago

I do not appear to have permission to push my local branch to the repo.

hfossli-agens commented 3 years ago

You fork and push to your fork then open a pull request :)

pheckenlWork commented 3 years ago

Thanks. For better or worse, most of my git experience with with corporate repos. PR is open.

hfossli-agens commented 3 years ago

The export func is intentionally private. Use .data() and then .DER or .PEM to export the key in your desired format. See example here https://github.com/agens-no/EllipticCurveKeyPair/blob/944ae5c89ca045e9f1a113b736706c73fc51d1c2/Demo-iOS/EncryptionViewController.swift#L98

Can you explain the other proposed changes? :)

pheckenlWork commented 3 years ago

I figured that the choice to make the export() method private was intentional. :-) In my use case, I'm trying to make a CSR, so exporting the bits directly was the quickest way to get where I needed to go.

I developed my solution on the latest MacOS with the latest Xcode. Xcode generated several deprecation warnings, and these code changes are my attempt to fix them.