fixed parsing of openssl format public keys
This commit is contained in:
@@ -29,7 +29,7 @@
|
|||||||
static const asn1Object_t pkinfoObjects[] = {
|
static const asn1Object_t pkinfoObjects[] = {
|
||||||
{ 0, "subjectPublicKeyInfo",ASN1_SEQUENCE, ASN1_NONE }, /* 0 */
|
{ 0, "subjectPublicKeyInfo",ASN1_SEQUENCE, ASN1_NONE }, /* 0 */
|
||||||
{ 1, "algorithm", ASN1_EOC, ASN1_RAW }, /* 1 */
|
{ 1, "algorithm", ASN1_EOC, ASN1_RAW }, /* 1 */
|
||||||
{ 1, "subjectPublicKey", ASN1_BIT_STRING, ASN1_OBJ }, /* 2 */
|
{ 1, "subjectPublicKey", ASN1_BIT_STRING, ASN1_BODY }, /* 2 */
|
||||||
{ 0, "exit", ASN1_EOC, ASN1_EXIT }
|
{ 0, "exit", ASN1_EOC, ASN1_EXIT }
|
||||||
};
|
};
|
||||||
#define PKINFO_SUBJECT_PUBLIC_KEY_ALGORITHM 1
|
#define PKINFO_SUBJECT_PUBLIC_KEY_ALGORITHM 1
|
||||||
@@ -73,13 +73,11 @@ static public_key_t *load(chunk_t blob)
|
|||||||
if (object.len > 0 && *object.ptr == 0x00)
|
if (object.len > 0 && *object.ptr == 0x00)
|
||||||
{
|
{
|
||||||
/* skip initial bit string octet defining 0 unused bits */
|
/* skip initial bit string octet defining 0 unused bits */
|
||||||
object.ptr++;
|
object = chunk_skip(object, 1);
|
||||||
object.len--;
|
|
||||||
key = lib->creds->create(lib->creds, CRED_PUBLIC_KEY, type,
|
|
||||||
BUILD_BLOB_ASN1_DER,
|
|
||||||
chunk_clone(object),
|
|
||||||
BUILD_END);
|
|
||||||
}
|
}
|
||||||
|
key = lib->creds->create(lib->creds, CRED_PUBLIC_KEY, type,
|
||||||
|
BUILD_BLOB_ASN1_DER, chunk_clone(object),
|
||||||
|
BUILD_END);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -731,22 +731,19 @@ static bool parse_certificate(private_x509_cert_t *this)
|
|||||||
if (object.len > 0 && *object.ptr == 0x00)
|
if (object.len > 0 && *object.ptr == 0x00)
|
||||||
{
|
{
|
||||||
/* skip initial bit string octet defining 0 unused bits */
|
/* skip initial bit string octet defining 0 unused bits */
|
||||||
object.ptr++;
|
object = chunk_skip(object, 1);
|
||||||
object.len--;
|
}
|
||||||
|
switch (key_alg)
|
||||||
switch (key_alg)
|
{
|
||||||
{
|
case OID_RSA_ENCRYPTION:
|
||||||
case OID_RSA_ENCRYPTION:
|
this->public_key = lib->creds->create(lib->creds,
|
||||||
this->public_key = lib->creds->create(lib->creds,
|
CRED_PUBLIC_KEY, KEY_RSA,
|
||||||
CRED_PUBLIC_KEY, KEY_RSA,
|
BUILD_BLOB_ASN1_DER, chunk_clone(object),
|
||||||
BUILD_BLOB_ASN1_DER,
|
BUILD_END);
|
||||||
chunk_clone(object),
|
break;
|
||||||
BUILD_END);
|
default:
|
||||||
break;
|
DBG1("parsing key type %d failed", key_alg);
|
||||||
default:
|
goto end;
|
||||||
DBG1("parsing key type %d failed", key_alg);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case X509_OBJ_EXTN_ID:
|
case X509_OBJ_EXTN_ID:
|
||||||
|
|||||||
Reference in New Issue
Block a user