This is a fork of the mbed port of axTLS
Dependents:
TLS_axTLS-Example
HTTPSClientExample
« Back to documentation index
crypto_misc.h File Reference
Go to the source code of this file.
Functions
int x509_new (const uint8_t *cert, int *len, X509_CTX **ctx)
Construct a new x509 object.
void x509_free (X509_CTX *x509_ctx)
Free an X.509 object's resources.
int x509_verify (PrecomputedCertificate *cert)
Do some basic checks on the certificate chain.
bigint * sig_verify (BI_CTX *ctx, const uint8_t *sig, int sig_len, bigint *modulus, bigint *pub_exp)
Take a signature and decrypt it.
int asn1_get_private_key (const uint8_t *buf, int len, RSA_CTX **rsa_ctx)
Get all the RSA private key specifics from an ASN.1 encoded file.
int asn1_next_obj (const uint8_t *buf, int *offset, int obj_type)
Skip the ASN1.1 object type and its length.
int asn1_skip_obj (const uint8_t *buf, int *offset, int obj_type)
Skip over an ASN.1 object type completely.
int asn1_get_int (const uint8_t *buf, int *offset, uint8_t **object)
Read an integer value for ASN.1 data Note: This function allocates memory which must be freed by the user.
int asn1_version (const uint8_t *cert, int *offset, X509_CTX *x509_ctx)
Get the version type of a certificate (which we don't actually care about)
int asn1_validity (const uint8_t *cert, int *offset, X509_CTX *x509_ctx)
Retrieve the notbefore and notafter certificate times.
int asn1_name (const uint8_t *cert, int *offset, char *dn[])
Get the subject name (or the issuer) of a certificate.
int asn1_public_key (const uint8_t *cert, int *offset, X509_CTX *x509_ctx)
Read the modulus and public exponent of a certificate.
int asn1_signature (const uint8_t *cert, int *offset, X509_CTX *x509_ctx)
Read the signature of the certificate.
int asn1_signature_type (const uint8_t *cert, int *offset, X509_CTX *x509_ctx)
Read the signature type of the certificate.
int get_file (const char *filename, uint8_t **buf)
Retrieve a file and put it into memory.
EXP_FUNC void STDCALL print_blob (const char *format, const uint8_t *data, int size,...)
Spit out a blob of data for diagnostics.
Detailed Description
Definition in file crypto_misc.h .
Function Documentation
int asn1_get_int
(
const uint8_t *
buf ,
int *
offset ,
uint8_t **
object
)
Read an integer value for ASN.1 data Note: This function allocates memory which must be freed by the user.
Definition at line 121 of file asn1.c .
int asn1_get_private_key
(
const uint8_t *
buf ,
int
len ,
RSA_CTX **
rsa_ctx
)
Get all the RSA private key specifics from an ASN.1 encoded file.
Definition at line 146 of file asn1.c .
int asn1_name
(
const uint8_t *
cert ,
int *
offset ,
char *
dn []
)
Get the subject name (or the issuer) of a certificate.
Definition at line 333 of file asn1.c .
int asn1_next_obj
(
const uint8_t *
buf ,
int *
offset ,
int
obj_type
)
Skip the ASN1.1 object type and its length.
Get ready to read the object's data.
Definition at line 94 of file asn1.c .
int asn1_public_key
(
const uint8_t *
cert ,
int *
offset ,
X509_CTX *
x509_ctx
)
Read the modulus and public exponent of a certificate.
Definition at line 386 of file asn1.c .
int asn1_signature
(
const uint8_t *
cert ,
int *
offset ,
X509_CTX *
x509_ctx
)
Read the signature of the certificate.
Definition at line 433 of file asn1.c .
int asn1_signature_type
(
const uint8_t *
cert ,
int *
offset ,
X509_CTX *
x509_ctx
)
Read the signature type of the certificate.
We only support RSA-MD5 and RSA-SHA1 signature types.
Definition at line 554 of file asn1.c .
int asn1_skip_obj
(
const uint8_t *
buf ,
int *
offset ,
int
obj_type
)
Skip over an ASN.1 object type completely.
Get ready to read the next object.
Definition at line 106 of file asn1.c .
int asn1_validity
(
const uint8_t *
cert ,
int *
offset ,
X509_CTX *
x509_ctx
)
Retrieve the notbefore and notafter certificate times.
Definition at line 257 of file asn1.c .
int asn1_version
(
const uint8_t *
cert ,
int *
offset ,
X509_CTX *
x509_ctx
)
Get the version type of a certificate (which we don't actually care about)
Definition at line 240 of file asn1.c .
int get_file
(
const char *
filename ,
uint8_t **
buf
)
Retrieve a file and put it into memory.
Returns: The size of the file, or -1 on failure.
Definition at line 71 of file crypto_misc.c .
EXP_FUNC void STDCALL print_blob
(
const char *
format ,
const uint8_t *
data ,
int
size ,
...
)
Spit out a blob of data for diagnostics.
The data is is a nice column format for easy reading.
Parameters:
format [in] The string (with possible embedded format characters)
size [in] The number of numbers to print
data [in] The start of data to use
... [in] Any additional arguments
Definition at line 274 of file crypto_misc.c .
Take a signature and decrypt it.
Definition at line 269 of file x509.c .
void x509_free
(
X509_CTX *
x509_ctx )
Free an X.509 object's resources.
Definition at line 228 of file x509.c .
int x509_new
(
const uint8_t *
cert ,
int *
len ,
X509_CTX **
ctx
)
Construct a new x509 object.
Returns: 0 if ok. < 0 if there was a problem.
Definition at line 75 of file x509.c .
int x509_verify
(
PrecomputedCertificate *
cert )
Do some basic checks on the certificate chain.
Certificate verification consists of a number of checks:
The date of the certificate is after the start date.
The date of the certificate is before the finish date.
A root certificate exists in the certificate store.
That the certificate(s) are not self-signed.
The certificate chain is valid.
The signature of the certificate is valid.
Definition at line 320 of file x509.c .