Implemented BUILD_BLOB_ASN1_DER for the CERT_TRUSTED_PUBKEY subtype
This commit is contained in:
@@ -19,6 +19,11 @@
|
|||||||
|
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* defined in pubkey_public_key.c
|
||||||
|
*/
|
||||||
|
extern public_key_t *pubkey_public_key_load(chunk_t blob);
|
||||||
|
|
||||||
typedef struct private_pubkey_cert_t private_pubkey_cert_t;
|
typedef struct private_pubkey_cert_t private_pubkey_cert_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -211,6 +216,13 @@ static pubkey_cert_t *pubkey_cert_create(public_key_t *key)
|
|||||||
return &this->public;
|
return &this->public;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static pubkey_cert_t *pubkey_cert_create_from_chunk(chunk_t blob)
|
||||||
|
{
|
||||||
|
public_key_t *key = pubkey_public_key_load(chunk_clone(blob));
|
||||||
|
|
||||||
|
return (key)? pubkey_cert_create(key) : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
typedef struct private_builder_t private_builder_t;
|
typedef struct private_builder_t private_builder_t;
|
||||||
/**
|
/**
|
||||||
* Builder implementation for key loading
|
* Builder implementation for key loading
|
||||||
@@ -244,6 +256,13 @@ static void add(private_builder_t *this, builder_part_t part, ...)
|
|||||||
|
|
||||||
switch (part)
|
switch (part)
|
||||||
{
|
{
|
||||||
|
case BUILD_BLOB_ASN1_DER:
|
||||||
|
{
|
||||||
|
va_start(args, part);
|
||||||
|
this->key = pubkey_cert_create_from_chunk(va_arg(args, chunk_t));
|
||||||
|
va_end(args);
|
||||||
|
return;
|
||||||
|
}
|
||||||
case BUILD_PUBLIC_KEY:
|
case BUILD_PUBLIC_KEY:
|
||||||
{
|
{
|
||||||
va_start(args, part);
|
va_start(args, part);
|
||||||
|
|||||||
@@ -39,9 +39,10 @@ static const asn1Object_t pkinfoObjects[] = {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a public key from an ASN1 encoded blob
|
* Load a public key from an ASN.1 encoded blob
|
||||||
|
* Also used by pubkey_cert.c
|
||||||
*/
|
*/
|
||||||
static public_key_t *load(chunk_t blob)
|
public_key_t *pubkey_public_key_load(chunk_t blob)
|
||||||
{
|
{
|
||||||
asn1_parser_t *parser;
|
asn1_parser_t *parser;
|
||||||
chunk_t object;
|
chunk_t object;
|
||||||
@@ -134,7 +135,7 @@ static void add(private_builder_t *this, builder_part_t part, ...)
|
|||||||
{
|
{
|
||||||
va_start(args, part);
|
va_start(args, part);
|
||||||
blob = va_arg(args, chunk_t);
|
blob = va_arg(args, chunk_t);
|
||||||
this->key = load(chunk_clone(blob));
|
this->key = pubkey_public_key_load(chunk_clone(blob));
|
||||||
va_end(args);
|
va_end(args);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -148,7 +149,7 @@ static void add(private_builder_t *this, builder_part_t part, ...)
|
|||||||
blob = chunk_clone(chunk_create(pem, strlen(pem)));
|
blob = chunk_clone(chunk_create(pem, strlen(pem)));
|
||||||
if (pem_to_bin(&blob, &chunk_empty, &pgp))
|
if (pem_to_bin(&blob, &chunk_empty, &pgp))
|
||||||
{
|
{
|
||||||
this->key = load(chunk_clone(blob));
|
this->key = pubkey_public_key_load(chunk_clone(blob));
|
||||||
}
|
}
|
||||||
free(blob.ptr);
|
free(blob.ptr);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|||||||
Reference in New Issue
Block a user