Virtual function table implemented by each cipher backend.
More...
#include <cipher.h>
|
| int(* | symmetric_encrypt )(const uint8_t *key, size_t key_len, const uint8_t *plaintext, size_t plaintext_len, const uint8_t *iv, size_t iv_len, uint8_t *ciphertext, size_t *ciphertext_len, uint8_t *tag, size_t tag_len) |
| | AES-256-GCM encryption.
|
| |
| int(* | symmetric_decrypt )(const uint8_t *key, size_t key_len, const uint8_t *ciphertext, size_t ciphertext_len, const uint8_t *iv, size_t iv_len, const uint8_t *tag, size_t tag_len, uint8_t *plaintext, size_t *plaintext_len) |
| | AES-256-GCM decryption with authentication tag verification.
|
| |
| int(* | generate_keypair )(char *public_key, size_t *pub_len, char *private_key, size_t *priv_len) |
| | Generate an RSA-2048 key pair.
|
| |
| int(* | asymmetric_encrypt )(const char *public_key, size_t pub_len, const uint8_t *plaintext, size_t plaintext_len, uint8_t *ciphertext, size_t *ciphertext_len) |
| | RSA-OAEP encryption.
|
| |
| int(* | asymmetric_decrypt )(const char *private_key, size_t priv_len, const uint8_t *ciphertext, size_t ciphertext_len, uint8_t *plaintext, size_t *plaintext_len) |
| | RSA-OAEP decryption.
|
| |
| int(* | sign )(const char *private_key, size_t priv_len, const uint8_t *data, size_t data_len, uint8_t *signature, size_t *sig_len) |
| | RSA-PSS signature generation.
|
| |
| int(* | verify )(const char *public_key, size_t pub_len, const uint8_t *data, size_t data_len, const uint8_t *signature, size_t sig_len) |
| | RSA-PSS signature verification.
|
| |
Virtual function table implemented by each cipher backend.
All function pointers must be non-NULL except where noted. Operations follow the same parameter patterns as their csilk* counterparts in internal.h so that the dispatch layer is transparent.
◆ asymmetric_decrypt
| int(* csilk_cipher_driver_t::asymmetric_decrypt) (const char *private_key, size_t priv_len, const uint8_t *ciphertext, size_t ciphertext_len, uint8_t *plaintext, size_t *plaintext_len) |
RSA-OAEP decryption.
- Parameters
-
| private_key | PEM-encoded RSA private key. |
| priv_len | Private key PEM length. |
| ciphertext | Data to decrypt. |
| ciphertext_len | Ciphertext length (typically 256). |
| [out] | plaintext | Output buffer. |
| [in,out] | plaintext_len | In: capacity, Out: actual plaintext length. |
- Returns
- 0 on success, -1 on failure.
◆ asymmetric_encrypt
| int(* csilk_cipher_driver_t::asymmetric_encrypt) (const char *public_key, size_t pub_len, const uint8_t *plaintext, size_t plaintext_len, uint8_t *ciphertext, size_t *ciphertext_len) |
RSA-OAEP encryption.
- Parameters
-
| public_key | PEM-encoded RSA public key. |
| pub_len | Public key PEM length. |
| plaintext | Data to encrypt (max ~190 bytes for RSA-2048). |
| plaintext_len | Plaintext length. |
| [out] | ciphertext | Output buffer (>= CSILK_RSA_KEY_SIZE bytes). |
| [in,out] | ciphertext_len | In: capacity, Out: actual ciphertext length. |
- Returns
- 0 on success, -1 on failure.
◆ generate_keypair
| int(* csilk_cipher_driver_t::generate_keypair) (char *public_key, size_t *pub_len, char *private_key, size_t *priv_len) |
Generate an RSA-2048 key pair.
- Parameters
-
| [out] | public_key | PEM-encoded public key output buffer. |
| [in,out] | pub_len | In: capacity, Out: actual PEM length. |
| [out] | private_key | PEM-encoded private key output buffer. |
| [in,out] | priv_len | In: capacity, Out: actual PEM length. |
- Returns
- 0 on success, -1 on failure.
◆ sign
| int(* csilk_cipher_driver_t::sign) (const char *private_key, size_t priv_len, const uint8_t *data, size_t data_len, uint8_t *signature, size_t *sig_len) |
RSA-PSS signature generation.
- Parameters
-
| private_key | PEM-encoded RSA private key. |
| priv_len | Private key PEM length. |
| data | Data to sign. |
| data_len | Data length. |
| [out] | signature | Output buffer (>= CSILK_RSA_SIGNATURE_SIZE bytes). |
| [in,out] | sig_len | In: capacity, Out: actual signature length. |
- Returns
- 0 on success, -1 on failure.
◆ symmetric_decrypt
| int(* csilk_cipher_driver_t::symmetric_decrypt) (const uint8_t *key, size_t key_len, const uint8_t *ciphertext, size_t ciphertext_len, const uint8_t *iv, size_t iv_len, const uint8_t *tag, size_t tag_len, uint8_t *plaintext, size_t *plaintext_len) |
AES-256-GCM decryption with authentication tag verification.
- Parameters
-
| key | Decryption key. |
| key_len | Key length. |
| ciphertext | Data to decrypt. |
| ciphertext_len | Ciphertext length. |
| iv | 12-byte nonce. |
| iv_len | 12. |
| tag | 16-byte authentication tag. |
| tag_len | 16. |
| [out] | plaintext | Output buffer (>= ciphertext_len bytes). |
| [in,out] | plaintext_len | In: capacity, Out: actual plaintext length. |
- Returns
- 0 on success, -1 on tag mismatch or error.
◆ symmetric_encrypt
| int(* csilk_cipher_driver_t::symmetric_encrypt) (const uint8_t *key, size_t key_len, const uint8_t *plaintext, size_t plaintext_len, const uint8_t *iv, size_t iv_len, uint8_t *ciphertext, size_t *ciphertext_len, uint8_t *tag, size_t tag_len) |
AES-256-GCM encryption.
- Parameters
-
| key | Encryption key (must be CSILK_AES256_KEY_SIZE bytes). |
| key_len | Key length (must be 32). |
| plaintext | Data to encrypt. |
| plaintext_len | Plaintext length. |
| iv | 12-byte nonce (must be CSILK_GCM_IV_SIZE bytes). |
| iv_len | 12. |
| [out] | ciphertext | Output buffer (>= plaintext_len bytes). |
| [in,out] | ciphertext_len | In: capacity, Out: actual ciphertext length. |
| [out] | tag | 16-byte authentication tag buffer. |
| tag_len | 16. |
- Returns
- 0 on success, -1 on failure.
◆ verify
| int(* csilk_cipher_driver_t::verify) (const char *public_key, size_t pub_len, const uint8_t *data, size_t data_len, const uint8_t *signature, size_t sig_len) |
RSA-PSS signature verification.
- Parameters
-
| public_key | PEM-encoded RSA public key. |
| pub_len | Public key PEM length. |
| data | Original signed data. |
| data_len | Data length. |
| signature | Signature to verify. |
| sig_len | Signature length. |
- Returns
- 0 on valid signature, -1 on invalid or error.
The documentation for this struct was generated from the following file: