XenevaOS
Loading...
Searching...
No Matches
Functions
rsa_internal.h File Reference

Internal-only RSA public-key cryptosystem API. More...

#include "mbedtls/rsa.h"
#include "mbedtls/asn1.h"
Include dependency graph for rsa_internal.h:

Go to the source code of this file.

Functions

int mbedtls_rsa_parse_key (mbedtls_rsa_context *rsa, const unsigned char *key, size_t keylen)
 Parse a PKCS#1 (ASN.1) encoded private RSA key.
 
int mbedtls_rsa_parse_pubkey (mbedtls_rsa_context *rsa, const unsigned char *key, size_t keylen)
 Parse a PKCS#1 (ASN.1) encoded public RSA key.
 
int mbedtls_rsa_write_key (const mbedtls_rsa_context *rsa, unsigned char *start, unsigned char **p)
 Write a PKCS#1 (ASN.1) encoded private RSA key.
 
int mbedtls_rsa_write_pubkey (const mbedtls_rsa_context *rsa, unsigned char *start, unsigned char **p)
 Parse a PKCS#1 (ASN.1) encoded public RSA key.
 

Detailed Description

Internal-only RSA public-key cryptosystem API.

This file declares RSA-related functions that are to be used only from within the Mbed TLS library itself.

Function Documentation

◆ mbedtls_rsa_parse_key()

int mbedtls_rsa_parse_key ( mbedtls_rsa_context *  rsa,
const unsigned char *  key,
size_t  keylen 
)

Parse a PKCS#1 (ASN.1) encoded private RSA key.

Parameters
rsaThe RSA context where parsed data will be stored.
keyThe buffer that contains the key.
keylenThe length of the key buffer in bytes.
Returns
0 on success.
MBEDTLS_ERR_ASN1_xxx in case of ASN.1 parsing errors.
MBEDTLS_ERR_RSA_xxx in case of RSA internal failures while parsing data.
MBEDTLS_ERR_RSA_KEY_CHECK_FAILED if validity checks on the provided key fail.

◆ mbedtls_rsa_parse_pubkey()

int mbedtls_rsa_parse_pubkey ( mbedtls_rsa_context *  rsa,
const unsigned char *  key,
size_t  keylen 
)

Parse a PKCS#1 (ASN.1) encoded public RSA key.

Parameters
rsaThe RSA context where parsed data will be stored.
keyThe buffer that contains the key.
keylenThe length of the key buffer in bytes.
Returns
0 on success.
MBEDTLS_ERR_ASN1_xxx in case of ASN.1 parsing errors.
MBEDTLS_ERR_RSA_xxx in case of RSA internal failures while parsing data.
MBEDTLS_ERR_RSA_KEY_CHECK_FAILED if validity checks on the provided key fail.

◆ mbedtls_rsa_write_key()

int mbedtls_rsa_write_key ( const mbedtls_rsa_context *  rsa,
unsigned char *  start,
unsigned char **  p 
)

Write a PKCS#1 (ASN.1) encoded private RSA key.

Parameters
rsaThe RSA context which contains the data to be written.
startBeginning of the buffer that will be filled with the private key.
pEnd of the buffer that will be filled with the private key. On successful return, the referenced pointer will be updated in order to point to the beginning of written data.
Returns
On success, the number of bytes written to the output buffer (i.e. a value > 0).
MBEDTLS_ERR_RSA_BAD_INPUT_DATA if the RSA context does not contain a valid key pair.
MBEDTLS_ERR_ASN1_xxx in case of failure while writing to the output buffer.
Note
The output buffer is filled backward, i.e. starting from its end and moving toward its start.

◆ mbedtls_rsa_write_pubkey()

int mbedtls_rsa_write_pubkey ( const mbedtls_rsa_context *  rsa,
unsigned char *  start,
unsigned char **  p 
)

Parse a PKCS#1 (ASN.1) encoded public RSA key.

Parameters
rsaThe RSA context which contains the data to be written.
startBeginning of the buffer that will be filled with the private key.
pEnd of the buffer that will be filled with the private key. On successful return, the referenced pointer will be updated in order to point to the beginning of written data.
Returns
On success, the number of bytes written to the output buffer (i.e. a value > 0).
MBEDTLS_ERR_RSA_BAD_INPUT_DATA if the RSA context does not contain a valid public key.
MBEDTLS_ERR_ASN1_xxx in case of failure while writing to the output buffer.
Note
The output buffer is filled backward, i.e. starting from its end and moving toward its start.