kodi
Classes | Macros | Typedefs | Functions | Variables
crypto_misc.h File Reference
#include "crypto.h"
#include "bigint.h"
Include dependency graph for crypto_misc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _x509_ctx
 

Macros

#define X509_OK   0
 
#define X509_NOT_OK   -1
 
#define X509_VFY_ERROR_NO_TRUSTED_CERT   -2
 
#define X509_VFY_ERROR_BAD_SIGNATURE   -3
 
#define X509_VFY_ERROR_NOT_YET_VALID   -4
 
#define X509_VFY_ERROR_EXPIRED   -5
 
#define X509_VFY_ERROR_SELF_SIGNED   -6
 
#define X509_VFY_ERROR_INVALID_CHAIN   -7
 
#define X509_VFY_ERROR_UNSUPPORTED_DIGEST   -8
 
#define X509_INVALID_PRIV_KEY   -9
 
#define X509_NUM_DN_TYPES   4
 
#define X509_COMMON_NAME   0
 
#define X509_ORGANIZATION   1
 
#define X509_ORGANIZATIONAL_UNIT   2
 
#define X509_GENERIC   3
 
#define ASN1_INTEGER   0x02
 
#define ASN1_BIT_STRING   0x03
 
#define ASN1_OCTET_STRING   0x04
 
#define ASN1_NULL   0x05
 
#define ASN1_PRINTABLE_STR2   0x0C
 
#define ASN1_OID   0x06
 
#define ASN1_UNIVERSAL_STR   0x1C /* GBG */
 
#define ASN1_PRINTABLE_STR   0x13
 
#define ASN1_TELETEX_STR   0x14
 
#define ASN1_IA5_STR   0x16
 
#define ASN1_UTC_TIME   0x17
 
#define ASN1_GENERALIZED_TIME   0x18 /* GBG */
 
#define ASN1_UNICODE_STR   0x1e
 
#define ASN1_SEQUENCE   0x30
 
#define ASN1_CONTEXT_DNSNAME   0x82
 
#define ASN1_SET   0x31
 
#define ASN1_V3_DATA   0xa3
 
#define ASN1_IMPLICIT_TAG   0x80
 
#define ASN1_CONTEXT_DNSNAME   0x82
 
#define ASN1_EXPLICIT_TAG   0xa0
 
#define ASN1_V3_DATA   0xa3
 
#define SIG_TYPE_MD2   0x02
 
#define SIG_TYPE_MD5   0x04
 
#define SIG_TYPE_SHA1   0x05
 
#define SIG_TYPE_SHA256   0x0B /* GBG */
 
#define SALT_SIZE   8
 

Typedefs

typedef struct _x509_ctx X509_CTX
 
typedef void(* crypt_func) (void *, const uint8_t *, uint8_t *, int)
 
typedef void(* hmac_func) (const uint8_t *msg, int length, const uint8_t *key, int key_len, uint8_t *digest)
 

Functions

int x509_new (const uint8_t *cert, int *len, X509_CTX **ctx)
 Construct a new x509 object. More...
 
void x509_free (X509_CTX *x509_ctx)
 Free an X.509 object's resources.
 
int get_asn1_length (const uint8_t *buf, int *offset)
 
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. More...
 
int asn1_skip_obj (const uint8_t *buf, int *offset, int obj_type)
 Skip over an ASN.1 object type completely. More...
 
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_type (const uint8_t *cert, int *offset, X509_CTX *x509_ctx)
 Read the signature type of the certificate. More...
 
int get_file (const char *filename, uint8_t **buf)
 
EXP_FUNC void STDCALL print_blob (const char *format, const uint8_t *data, int size,...)
 
EXP_FUNC int STDCALL base64_decode (const char *in, int len, uint8_t *out, int *outlen)
 

Variables

const char *const unsupported_str
 

Function Documentation

◆ asn1_next_obj()

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.

◆ asn1_signature_type()

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.

◆ asn1_skip_obj()

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.

◆ x509_new()

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.