CryptoSys PKI
23.0.0
|
Elliptic curve cryptography. More...
Public Types | |
enum class | Curve |
Supported curves. More... | |
enum class | Format |
Format for output files. More... | |
enum class | KeyType |
Key type for unencrypted key file. More... | |
enum class | PbeScheme |
Password-based encryption scheme to encrypt the private key file. More... | |
enum class | Publicity |
State of key being public or private. More... | |
Static Public Member Functions | |
static std::string | CurveNameAsString (Curve curve) |
Get curve name as a string. More... | |
static bvec_t | DHSharedSecret (std::string ourIntPrivateKey, std::string theirIntPublicKey) |
Compute EC Diffie-Hellman (ECDH) shared secret. More... | |
static uint32_t | KeyHashCode (std::string intKeyString) |
Compute the hash code of an "internal" ECC public or private key string. More... | |
static int | MakeKeys (const std::string &publicKeyFile, const std::string &privateKeyFile, Curve curve, const std::string &password, PbeScheme pbes=PbeScheme::Default, const std::string ¶mString="", Format fileFormat=Format::Binary) |
Generate an EC public/private key pair and save as two key files. More... | |
static std::string | PublicKeyFromPrivate (std::string internalKey) |
Convert an internal EC private key string into an internal EC public key string. More... | |
static std::string | QueryKey (std::string internalKey, std::string query) |
Query an EC key string for selected information. More... | |
static std::string | ReadKeyByCurve (std::string hexKey, Curve curve, Publicity publicity=Publicity::PrivateKey) |
Read an EC key from its hexadecimal representation. More... | |
static std::string | ReadPrivateKey (std::string keyFileOrString, std::string password="") |
Read from a file or a string containing an EC private key into an "internal" private key string. More... | |
static std::string | ReadPublicKey (std::string keyFileOrString) |
Read from a file or a string containing an EC public key into an "internal" public key string. More... | |
static int | SaveEncKey (std::string outputFile, std::string internalKey, std::string password, PbeScheme pbes=PbeScheme::Default, std::string paramString="", Format fileFormat=Format::Binary) |
Save an internal EC private key string to an encrypted private key file. More... | |
static int | SaveKey (std::string outputFile, std::string internalKey, KeyType keyType=KeyType::Default, Format fileFormat=Format::Binary) |
Save an internal EC key string (public or private) to an unencrypted key file. More... | |
Elliptic curve cryptography.
|
strong |
Supported curves.
|
strong |
|
strong |
|
strong |
Password-based encryption scheme to encrypt the private key file.
|
strong |
|
static |
Get curve name as a string.
curve | Curve |
"secp256r1"
.
|
static |
Compute EC Diffie-Hellman (ECDH) shared secret.
ourIntPrivateKey | Our own private key in ephemeral "internal" form. |
theirIntPublicKey | Other party's public key in "internal" form. |
|
static |
Compute the hash code of an "internal" ECC public or private key string.
intKeyString | Key as an internal key string. |
|
static |
Generate an EC public/private key pair and save as two key files.
publicKeyFile | Output filename for public key. |
privateKeyFile | Output filename for (encrypted) private key. |
curve | Elliptic curve |
password | Password for encrypted private key (required). |
pbes | Encryption scheme to encrypt private key. |
paramString | Optional parameters. A set of attribute name=value pairs separated by a semicolon ";" (see remarks). |
fileFormat | Format to save file (default = DER binary). |
paramString
are: Parameter | Result |
---|---|
count=integer | To set the iteration count used in the PBKDF2 method, e.g. "count=5000;" [default=2048]. |
prf=hmac-name | To change the HMAC algorithm used in the PBKDF2 method, e.g. "prf=hmacWithSHA256;" [default=hmacWithSHA1 ]. |
{hmacWithSHA1,hmacWithSHA224,hmacWithSHA256,hmacWithSHA384,hmacWithSHA512}
.
|
static |
Convert an internal EC private key string into an internal EC public key string.
internalKey | Private key as an internal key string. |
|
static |
Query an EC key string for selected information.
internalKey | Key as an internal key string. |
query | Query string (case insensitive). |
Query String | Returns |
---|---|
curveName | Name of the curve. |
keyBits | Number of bits in the key. |
isPrivate | "1" if key is a private key; "0" if not. |
isValid | "1" if key is validated; "0" if not. |
privateKey | Value of the private key encoded in hex. |
publicKey | Value of the public key encoded in hex. |
std::runtime_error | Exception with error code if internal key string or query is invalid. |
|
static |
Read an EC key from its hexadecimal representation.
hexKey | Hexadecimal representation of the key, private or public. |
curve | Elliptic curve. |
publicity | Required to read a safe curve key, otherwise ignored [default=PrivateKey ]. |
w
is represented as HEX(w)
and a public key (x,y)
in the uncompressed X9.63 form 04||HEX(x)||HEX(y)
. The key type is detected automatically and the publicity
argument is ignored. publicity
argument must be used to must specify whether the key is a private or public key.
|
static |
Read from a file or a string containing an EC private key into an "internal" private key string.
keyFileOrString | Name of private key file or a PEM String containing the key. |
password | Password for private key, if encrypted. |
|
static |
Read from a file or a string containing an EC public key into an "internal" public key string.
keyFileOrString | Name of public key file or a PEM String containing the key. |
|
static |
Save an internal EC private key string to an encrypted private key file.
outputFile | Name of key file to be created. |
internalKey | The private EC key as an internal key string. |
password | Password to be used for the encrypted key file |
pbes | Password-based encryption scheme to encrypt private key. |
paramString | Optional parameters. A set of attribute name=value pairs separated by a semicolon ";" (see remarks). Set as "" for defaults. |
fileFormat | Format to save file (default = DER binary) |
paramString
are: Parameter | Result |
---|---|
count=integer | To set the iteration count used in the PBKDF2 method, e.g. "count=5000;" [default=2048]. |
prf=hmac-name | To change the HMAC algorithm used in the PBKDF2 method, e.g. "prf=hmacWithSHA256;" [default=hmacWithSHA1 ]. |
{hmacWithSHA1,hmacWithSHA224,hmacWithSHA256,hmacWithSHA384,hmacWithSHA512}
.
|
static |
Save an internal EC key string (public or private) to an unencrypted key file.
outputFile | Name of key file to be created. |
internalKey | The private or public EC key as an internal key string. |
keyType | Key structure for private key (ignored for public). |
fileFormat | Format to save file (default = DER binary) |