/* * Load one or more CRLs and add them to the chained list */ int mbedtls_x509_crl_parse_file(mbedtls_x509_crl *chain, const char *path) { int ret; size_t n; unsigned char *buf; if ((ret = mbedtls_pk_load_file(path, &buf, &n)) != 0) return (ret); ret = mbedtls_x509_crl_parse(chain, buf, n); mbedtls_zeroize(buf, n); mbedtls_free(buf); return (ret); }
/* * Load and parse a public key */ int mbedtls_pk_parse_public_keyfile( mbedtls_pk_context *ctx, const char *path ) { int ret; size_t n; unsigned char *buf; if( ( ret = mbedtls_pk_load_file( path, &buf, &n ) ) != 0 ) return( ret ); ret = mbedtls_pk_parse_public_key( ctx, buf, n ); mbedtls_zeroize( buf, n ); mbedtls_free( buf ); return( ret ); }
/* * Load and parse a private key */ int mbedtls_pk_parse_keyfile( mbedtls_pk_context *ctx, const char *path, const char *pwd ) { int ret; size_t n; unsigned char *buf; if( ( ret = mbedtls_pk_load_file( path, &buf, &n ) ) != 0 ) return( ret ); if( pwd == NULL ) ret = mbedtls_pk_parse_key( ctx, buf, n, NULL, 0 ); else ret = mbedtls_pk_parse_key( ctx, buf, n, (const unsigned char *) pwd, strlen( pwd ) ); mbedtls_zeroize( buf, n ); mbedtls_free( buf ); return( ret ); }