« 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 (const CA_CERT_CTX *ca_cert_ctx, const X509_CTX *cert)
Do some basic checks on the certificate chain.
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 145 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 331 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 93 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 384 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 416 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 537 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 105 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 255 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 239 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 .
void x509_free
(
X509_CTX *
x509_ctx )
Free an X.509 object's resources.
Definition at line 227 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 73 of file x509.c .
int x509_verify
(
const CA_CERT_CTX *
ca_cert_ctx ,
const X509_CTX *
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 318 of file x509.c .