
ISARA Radiate™ Quantum-safe Library Version 3.1
Quantum-safe cryptographic primitives and algorithms.
ISARA Radiate Quantum-Safe Library's ClassicMcEliece KEM. More...
Macros | |
#define | IQR_CLASSICMCELIECE_SHARED_KEY_SIZE 32 |
Typedefs | |
typedef struct iqr_ClassicMcElieceParams_struct | iqr_ClassicMcElieceParams |
typedef struct iqr_ClassicMcEliecePublicKey_struct | iqr_ClassicMcEliecePublicKey |
typedef struct iqr_ClassicMcEliecePrivateKey_struct | iqr_ClassicMcEliecePrivateKey |
typedef struct iqr_ClassicMcElieceVariant_struct | iqr_ClassicMcElieceVariant |
Variables | |
const IQR_EXTERN iqr_ClassicMcElieceVariant | IQR_CLASSICMCELIECE_6 |
const IQR_EXTERN iqr_ClassicMcElieceVariant | IQR_CLASSICMCELIECE_8 |
Macro Definition Documentation
◆ IQR_CLASSICMCELIECE_SHARED_KEY_SIZE
#define IQR_CLASSICMCELIECE_SHARED_KEY_SIZE 32 |
The size of the shared key produced by ClassicMcEliece in bytes.
Typedef Documentation
◆ iqr_ClassicMcElieceParams
typedef struct iqr_ClassicMcElieceParams_struct iqr_ClassicMcElieceParams |
The algorithm's domain parameters.
◆ iqr_ClassicMcEliecePrivateKey
typedef struct iqr_ClassicMcEliecePrivateKey_struct iqr_ClassicMcEliecePrivateKey |
The ClassicMcEliece private key.
◆ iqr_ClassicMcEliecePublicKey
typedef struct iqr_ClassicMcEliecePublicKey_struct iqr_ClassicMcEliecePublicKey |
The ClassicMcEliece public key.
◆ iqr_ClassicMcElieceVariant
typedef struct iqr_ClassicMcElieceVariant_struct iqr_ClassicMcElieceVariant |
The ClassicMcEliece variant. This controls the amount of security.
Function Documentation
◆ iqr_ClassicMcElieceCreateKeyPair()
IQR_API iqr_retval iqr_ClassicMcElieceCreateKeyPair | ( | const iqr_ClassicMcElieceParams * | params, |
const iqr_RNG * | rng, | ||
iqr_ClassicMcEliecePublicKey ** | public_key, | ||
iqr_ClassicMcEliecePrivateKey ** | private_key | ||
) |
Generate a ClassicMcEliece private/public key pair.
The rng must be initialized before being passed to iqr_ClassicMcElieceCreateKeyPair()
.
*public_key and *private_key must be set to NULL
before calling iqr_ClassicMcElieceCreateKeyPair()
.
- Parameters
-
[in] params The ClassicMcEliece parameters. [in] rng A seeded random number generator. [out] public_key The resulting iqr_ClassicMcEliecePublicKey
object.[out] private_key The resulting iqr_ClassicMcEliecePrivateKey
object.
- Returns
IQR_OK
on success, or another value from iqr_retval.h if an error occurs.
◆ iqr_ClassicMcElieceCreateParams()
IQR_API iqr_retval iqr_ClassicMcElieceCreateParams | ( | const iqr_Context * | ctx, |
const iqr_ClassicMcElieceVariant * | variant, | ||
iqr_ClassicMcElieceParams ** | params | ||
) |
Create a parameter object for the ClassicMcEliece cryptographic system.
*params must be set to NULL
before calling iqr_ClassicMcElieceCreateParams()
.
- Parameters
-
[in] ctx A Context object. [in] variant iqr_ClassicMcElieceVariant
to use.[out] params The ClassicMcEliece parameter object.
- Returns
IQR_OK
on success, or another value from iqr_retval.h if an error occurs.
◆ iqr_ClassicMcElieceDecapsulate()
IQR_API iqr_retval iqr_ClassicMcElieceDecapsulate | ( | const iqr_ClassicMcEliecePrivateKey * | private_key, |
const uint8_t * | ciphertext, | ||
size_t | ciphertext_size, | ||
uint8_t * | shared_key, | ||
size_t | shared_key_size | ||
) |
ClassicMcEliece decapsulation.
Creates a shared key from a ciphertext. This will be the same shared key that was generated by iqr_ClassicMcElieceEncapsulate()
when the ciphertext was created.
All internal buffers are cleared and deallocated before the call to iqr_ClassicMcElieceDecapsulate()
returns. Be sure to safely wipe and deallocate the shared_key when you're done with it.
- Parameters
-
[in] private_key Input private key. [in] ciphertext The input ciphertext. [in] ciphertext_size The size of ciphertext in bytes. Must be exactly the size returned by iqr_ClassicMcElieceGetCiphertextSize()
.[out] shared_key The resulting shared key. [in] shared_key_size The size of shared_key in bytes. Must be exactly IQR_CLASSICMCELIECE_SHARED_KEY_SIZE
bytes.
- Returns
IQR_OK
on success, or another value from iqr_retval.h if an error occurs.
◆ iqr_ClassicMcElieceDestroyParams()
IQR_API_UNENFORCED_RETURN iqr_retval iqr_ClassicMcElieceDestroyParams | ( | iqr_ClassicMcElieceParams ** | params | ) |
Clear and deallocate a ClassicMcEliece parameter object.
params is set to NULL
prior to returning.
All internal iqr_ClassicMcElieceParams
buffers are cleared and deallocated during the call to iqr_ClassicMcElieceDestroyParams()
. The iqr_ClassicMcElieceParams
object does not store any cryptographic material.
- Parameters
-
[in,out] params The ClassicMcEliece parameter object to destroy.
- Returns
IQR_OK
on success, or another value from iqr_retval.h if an error occurs.
◆ iqr_ClassicMcElieceDestroyPrivateKey()
IQR_API_UNENFORCED_RETURN iqr_retval iqr_ClassicMcElieceDestroyPrivateKey | ( | iqr_ClassicMcEliecePrivateKey ** | private_key | ) |
Clear and deallocate a ClassicMcEliece private key.
private_key is set to NULL
prior to returning.
The private key's data is cleared before its internal buffers are deallocated.
- Parameters
-
[in,out] private_key The iqr_ClassicMcEliecePrivateKey
object to destroy.
- Returns
IQR_OK
on success, or another value from iqr_retval.h if an error occurs.
◆ iqr_ClassicMcElieceDestroyPublicKey()
IQR_API_UNENFORCED_RETURN iqr_retval iqr_ClassicMcElieceDestroyPublicKey | ( | iqr_ClassicMcEliecePublicKey ** | public_key | ) |
Clear and deallocate a ClassicMcEliece public key.
public_key is set to NULL
prior to returning.
- Parameters
-
[in,out] public_key The iqr_ClassicMcEliecePublicKey
object to destroy.
- Returns
IQR_OK
on success, or another value from iqr_retval.h if an error occurs.
◆ iqr_ClassicMcElieceEncapsulate()
IQR_API iqr_retval iqr_ClassicMcElieceEncapsulate | ( | const iqr_ClassicMcEliecePublicKey * | public_key, |
const iqr_RNG * | rng, | ||
uint8_t * | ciphertext, | ||
size_t | ciphertext_size, | ||
uint8_t * | shared_key, | ||
size_t | shared_key_size | ||
) |
ClassicMcEliece encapsulation.
Creates a shared key and a ciphertext. When iqr_ClassicMcElieceDecapsulate()
is called on the ciphertext and corresponding private key the same shared key will be generated.
The rng must be initialized before being passed to iqr_ClassicMcElieceEncapsulate()
.
All internal buffers are cleared and deallocated before the call to iqr_ClassicMcElieceEncapsulate()
returns. Be sure to safely wipe and deallocate the shared_key when you're done with it.
- Parameters
-
[in] public_key Input public key. [in] rng A seeded random number generator. [out] ciphertext The resulting ciphertext. [in] ciphertext_size The size of ciphertext in bytes. Must be exactly the size returned by iqr_ClassicMcElieceGetCiphertextSize()
[out] shared_key The resulting shared key. [in] shared_key_size The size of shared_key in bytes. Must be exactly IQR_CLASSICMCELIECE_SHARED_KEY_SIZE
bytes.
- Returns
IQR_OK
on success, or another value from iqr_retval.h if an error occurs.
◆ iqr_ClassicMcElieceExportPrivateKey()
IQR_API iqr_retval iqr_ClassicMcElieceExportPrivateKey | ( | const iqr_ClassicMcEliecePrivateKey * | private_key, |
uint8_t * | buf, | ||
size_t | buf_size | ||
) |
Export the ClassicMcEliece private key's data into a buffer.
Be sure to safely wipe and discard buf when you're done using it.
- Parameters
-
[in] private_key The private key object. [out] buf The destination buffer. [in] buf_size The size of buf in bytes. Must be exactly the size returned by iqr_ClassicMcElieceGetPrivateKeySize()
.
- Returns
IQR_OK
on success, or another value from iqr_retval.h if an error occurs.
◆ iqr_ClassicMcElieceExportPublicKey()
IQR_API iqr_retval iqr_ClassicMcElieceExportPublicKey | ( | const iqr_ClassicMcEliecePublicKey * | public_key, |
uint8_t * | buf, | ||
size_t | buf_size | ||
) |
Export the ClassicMcEliece public key's data into a buffer.
- Parameters
-
[in] public_key The public key object. [out] buf The destination buffer. [in] buf_size The size of buf in bytes. Must be exactly the size returned by iqr_ClassicMcElieceGetPublicKeySize()
.
- Returns
IQR_OK
on success, or another value from iqr_retval.h if an error occurs.
◆ iqr_ClassicMcElieceGetCiphertextSize()
IQR_API iqr_retval iqr_ClassicMcElieceGetCiphertextSize | ( | const iqr_ClassicMcElieceParams * | params, |
size_t * | ciphertext_size | ||
) |
Get the size of the ciphertext.
- Parameters
-
[in] params The iqr_ClassicMcElieceParams
to use.[out] ciphertext_size The size of the ciphertext in bytes.
- Returns
IQR_OK
on success, or another value from iqr_retval.h if an error occurs.
◆ iqr_ClassicMcElieceGetPrivateKeySize()
IQR_API iqr_retval iqr_ClassicMcElieceGetPrivateKeySize | ( | const iqr_ClassicMcElieceParams * | params, |
size_t * | private_key_size | ||
) |
Get the size of the private key.
- Parameters
-
[in] params The iqr_ClassicMcElieceParams
to use.[out] private_key_size The size of the private key in bytes.
- Returns
IQR_OK
on success, or another value from iqr_retval.h if an error occurs.
◆ iqr_ClassicMcElieceGetPublicKeySize()
IQR_API iqr_retval iqr_ClassicMcElieceGetPublicKeySize | ( | const iqr_ClassicMcElieceParams * | params, |
size_t * | public_key_size | ||
) |
Get the size of the public key.
- Parameters
-
[in] params The iqr_ClassicMcElieceParams
to use.[out] public_key_size The size of the public key in bytes.
- Returns
IQR_OK
on success, or another value from iqr_retval.h if an error occurs.
◆ iqr_ClassicMcElieceGetSharedKeySize()
IQR_API iqr_retval iqr_ClassicMcElieceGetSharedKeySize | ( | const iqr_ClassicMcElieceParams * | params, |
size_t * | shared_key_size | ||
) |
Get the size of the shared key.
- Parameters
-
[in] params The iqr_ClassicMcElieceParams
to use.[out] shared_key_size The size of the shared key in bytes.
- Returns
IQR_OK
on success, or another value from iqr_retval.h if an error occurs.
◆ iqr_ClassicMcElieceImportPrivateKey()
IQR_API iqr_retval iqr_ClassicMcElieceImportPrivateKey | ( | const iqr_ClassicMcElieceParams * | params, |
const uint8_t * | buf, | ||
size_t | buf_size, | ||
iqr_ClassicMcEliecePrivateKey ** | private_key | ||
) |
Import a ClassicMcEliece private key object from a buffer.
- Note
- This function only accepts data that has been generated by
iqr_ClassicMcElieceExportPrivateKey()
. There is currently no standard for saving ClassicMcEliece private keys.
*private_key must be set to NULL
before calling iqr_ClassicMcElieceImportPrivateKey()
. Be sure to safely wipe and discard buf after calling this function.
- Parameters
-
[in] params The ClassicMcEliece parameters. [in] buf A buffer that contains a private key. [in] buf_size The size of buf in bytes. Must be exactly the size returned by iqr_ClassicMcElieceGetPrivateKeySize()
.[out] private_key The resulting iqr_ClassicMcEliecePrivateKey
object.
- Returns
IQR_OK
on success, or another value from iqr_retval.h if an error occurs.
◆ iqr_ClassicMcElieceImportPublicKey()
IQR_API iqr_retval iqr_ClassicMcElieceImportPublicKey | ( | const iqr_ClassicMcElieceParams * | params, |
const uint8_t * | buf, | ||
size_t | buf_size, | ||
iqr_ClassicMcEliecePublicKey ** | public_key | ||
) |
Import a ClassicMcEliece public key object from a buffer.
*public_key must be set to NULL
before calling iqr_ClassicMcElieceImportPublicKey()
.
- Parameters
-
[in] params The ClassicMcEliece parameters. [in] buf A buffer that contains a public key. [in] buf_size The size of buf in bytes. Must be exactly the size returned by iqr_ClassicMcElieceGetPublicKeySize()
.[out] public_key The resulting iqr_ClassicMcEliecePublicKey
object.
- Returns
IQR_OK
on success, or another value from iqr_retval.h if an error occurs.
Variable Documentation
◆ IQR_CLASSICMCELIECE_6
const IQR_EXTERN iqr_ClassicMcElieceVariant IQR_CLASSICMCELIECE_6 |
6960119 variant (256 bit classical security) from the specification.
◆ IQR_CLASSICMCELIECE_8
const IQR_EXTERN iqr_ClassicMcElieceVariant IQR_CLASSICMCELIECE_8 |
8192128 variant (256 bit classical security) from the specification.
Detailed Description
ISARA Radiate Quantum-Safe Library's ClassicMcEliece KEM.
An implementation of ClassicMcEliece as defined in Classic McEliece.
- Copyright
- Copyright (C) 2018-2023, ISARA Corporation, All Rights Reserved.
- License
- The code and other content set out herein is not in the public domain, is considered a trade secret and is confidential to ISARA Corporation. Use, reproduction or distribution, in whole or in part, of such code or other content is strictly prohibited except by express written permission of ISARA Corporation. Please contact ISARA Corporation at info@ for more information. isar a.com