Classes
The following classes are available globally.
-
Represents an elliptic curve private key.
Supported curves are:- prime256v1
- secp384r1
- NID_secp521r1
You can generate an elliptic curve Key using OpenSSL:
https://wiki.openssl.org/index.php/Command_Line_Elliptic_Curve_Operations#Generating_EC_Keys_and_Parameters
Usage Example:
See morelet pemKey = """ -----BEGIN EC PRIVATE KEY----- MHcCAQEEIJX+87WJ7Gh19sohyZnhxZeXYNOcuGv4Q+8MLge4UkaZoAoGCCqGSM49 AwEHoUQDQgAEikc5m6C2xtDWeeAeT18WElO37zvFOz8p4kAlhvgIHN23XIClNESg KVmLgSSq2asqiwdrU5YHbcHFkgdABM1SPA== -----END EC PRIVATE KEY----- """ let privateKey = try ECPrivateKey(key: pemKey) let signature = "Hello world".sign(with: privateKey)
Declaration
Swift
public class ECPrivateKey
- prime256v1
-
Represents an elliptic curve public key. Supported curves are:
- prime256v1
- secp384r1
- NID_secp521r1
You can generate an elliptic curve Key using OpenSSL:
https://wiki.openssl.org/index.php/Command_Line_Elliptic_Curve_Operations#Generating_EC_Keys_and_Parameters
Usage Example:
See morelet pemKey = """ -----BEGIN PUBLIC KEY----- MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEikc5m6C2xtDWeeAeT18WElO37zvF Oz8p4kAlhvgIHN23XIClNESgKVmLgSSq2asqiwdrU5YHbcHFkgdABM1SPA== -----END PUBLIC KEY----- """ let publicKey = try ECPublicKey(key: pemKey) let base64Sig = "MEYCIQCvgBLn+tQoBDBR3D2G3485GloYGNxuk6PqR4qjr5GDqAIhAKNvsqvesVBD/MLub/KAyzLLNGtUZyQDxYZj/4vmHwWF" let signature = try ECSignature(asn1: Data(base64Encoded: base64Sig)) let verified = signature.verify(plaintext: "Hello world", using: publicKey)
Declaration
Swift
public class ECPublicKey
- prime256v1