Class for using PKCS1 (Public-Key Cryptography Standards Version 1) asymmetric encryption/decryption for signing and verification.
More...
#include <signaturepkcs1.h>
|
virtual | ~SignaturePkcs1 ()=default |
|
virtual State | setPublicKey (const uint8_t n[], size_t nLen, const uint8_t e[], size_t eLen)=0 |
| Pass the modulus N and public key E to the class. More...
|
|
virtual State | setPrivateKey (const uint8_t n[], size_t nLen, const uint8_t d[], size_t dLen)=0 |
| Pass the modulus N and private key D to the class. More...
|
|
virtual State | sign (const uint8_t hashDigest[], size_t hashBitLen, uint8_t sign[], HashAlgorithm hashAlgorithm)=0 |
| The function executes a hash algorithm on the given data, and signs the hash-digest using the private key. More...
|
|
virtual State | verify (const uint8_t hashDigest[], size_t hashBitLen, const uint8_t sign[], HashAlgorithm hashAlgorithm)=0 |
| The function executes a verification of the data data with the given signature sign . More...
|
|
Class for using PKCS1 (Public-Key Cryptography Standards Version 1) asymmetric encryption/decryption for signing and verification.
- Note
- The format of the keys (public and private), modular and the data is big endian, where the MSByte is places at the byte with the minimum address.
-
The size of the public key
E
and private key D
must be less the modulus N
.
Definition at line 26 of file signaturepkcs1.h.
◆ HashAlgorithm
◆ State
Enum for the output state of the function.
Definition at line 30 of file signaturepkcs1.h.
◆ ~SignaturePkcs1()
virtual semf::app::SignaturePkcs1::~SignaturePkcs1 |
( |
| ) |
|
|
virtualdefault |
◆ setPrivateKey()
virtual State semf::app::SignaturePkcs1::setPrivateKey |
( |
const uint8_t |
n[], |
|
|
size_t |
nLen, |
|
|
const uint8_t |
d[], |
|
|
size_t |
dLen |
|
) |
| |
|
pure virtual |
Pass the modulus N
and private key D
to the class.
The size of the message m
must fulfill 0 <= m < n.
- Parameters
-
n | Pointer to the address of the modulus (in binary form). |
nLen | Size of the modulus in bytes. |
d | Pointer to the address of the private key (in binary form). |
dLen | Size of the private key in bytes. |
- Returns
STATE::OK
on success and STATE::FAILED
on failure.
◆ setPublicKey()
virtual State semf::app::SignaturePkcs1::setPublicKey |
( |
const uint8_t |
n[], |
|
|
size_t |
nLen, |
|
|
const uint8_t |
e[], |
|
|
size_t |
eLen |
|
) |
| |
|
pure virtual |
Pass the modulus N
and public key E
to the class.
The size of the message m
must fulfill 0 <= m < n.
- Parameters
-
n | Pointer to the address of the modulus (in binary form). |
nLen | Size of the modulus in bytes. |
e | Pointer to the address of the public key (in binary form). |
eLen | Size of the public key in bytes. |
- Returns
STATE::OK
on success and STATE::FAILED
on failure.
◆ sign()
virtual State semf::app::SignaturePkcs1::sign |
( |
const uint8_t |
hashDigest[], |
|
|
size_t |
hashBitLen, |
|
|
uint8_t |
sign[], |
|
|
HashAlgorithm |
hashAlgorithm |
|
) |
| |
|
pure virtual |
The function executes a hash algorithm on the given data, and signs the hash-digest using the private key.
- Parameters
-
hashDigest | The hash which should be signed. |
hashBitLen | The size of the hash checksum in bits. |
sign | The signature produced from the function, it has the same size of the modular N . |
hashAlgorithm | The hash function which is performed on the input data. |
- Returns
STATE::OK
on success and STATE::FAILED
on failure.
◆ verify()
virtual State semf::app::SignaturePkcs1::verify |
( |
const uint8_t |
hashDigest[], |
|
|
size_t |
hashBitLen, |
|
|
const uint8_t |
sign[], |
|
|
HashAlgorithm |
hashAlgorithm |
|
) |
| |
|
pure virtual |
The function executes a verification of the data data
with the given signature sign
.
- Parameters
-
hashDigest | The hash which should be verified. |
hashBitLen | The size of the hash checksum in bits. |
sign | The claimed signature, it is decrypted and compared to the hash-digest of the data.N . |
hashAlgorithm | The hash function which is performed on the input data. |
- Returns
STATE::OK
on success and STATE::FAILED
on failure.