Also log PGP parsing in ASN log group.
This commit is contained in:
@@ -286,18 +286,18 @@ static bool parse_public_key(private_pgp_cert_t *this, chunk_t packet)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
DBG1(DBG_LIB, "PGP packet version V%d not supported",
|
DBG1(DBG_ASN, "PGP packet version V%d not supported",
|
||||||
this->version);
|
this->version);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (this->valid)
|
if (this->valid)
|
||||||
{
|
{
|
||||||
DBG2(DBG_LIB, "L2 - created %T, valid %d days", &this->created, FALSE,
|
DBG2(DBG_ASN, "L2 - created %T, valid %d days", &this->created, FALSE,
|
||||||
this->valid);
|
this->valid);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DBG2(DBG_LIB, "L2 - created %T, never expires", &this->created, FALSE);
|
DBG2(DBG_ASN, "L2 - created %T, never expires", &this->created, FALSE);
|
||||||
}
|
}
|
||||||
DESTROY_IF(this->key);
|
DESTROY_IF(this->key);
|
||||||
this->key = lib->creds->create(lib->creds, CRED_PUBLIC_KEY, KEY_ANY,
|
this->key = lib->creds->create(lib->creds, CRED_PUBLIC_KEY, KEY_ANY,
|
||||||
@@ -318,13 +318,13 @@ static bool parse_public_key(private_pgp_cert_t *this, chunk_t packet)
|
|||||||
hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1);
|
hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1);
|
||||||
if (hasher == NULL)
|
if (hasher == NULL)
|
||||||
{
|
{
|
||||||
DBG1(DBG_LIB, "no SHA-1 hasher available");
|
DBG1(DBG_ASN, "no SHA-1 hasher available");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
hasher->allocate_hash(hasher, pubkey_packet_header, NULL);
|
hasher->allocate_hash(hasher, pubkey_packet_header, NULL);
|
||||||
hasher->allocate_hash(hasher, pubkey_packet, &this->fingerprint);
|
hasher->allocate_hash(hasher, pubkey_packet, &this->fingerprint);
|
||||||
hasher->destroy(hasher);
|
hasher->destroy(hasher);
|
||||||
DBG2(DBG_LIB, "L2 - v4 fingerprint %#B", &this->fingerprint);
|
DBG2(DBG_ASN, "L2 - v4 fingerprint %#B", &this->fingerprint);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -335,7 +335,7 @@ static bool parse_public_key(private_pgp_cert_t *this, chunk_t packet)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
this->fingerprint = chunk_clone(this->fingerprint);
|
this->fingerprint = chunk_clone(this->fingerprint);
|
||||||
DBG2(DBG_LIB, "L2 - v3 fingerprint %#B", &this->fingerprint);
|
DBG2(DBG_ASN, "L2 - v3 fingerprint %#B", &this->fingerprint);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -355,7 +355,7 @@ static bool parse_signature(private_pgp_cert_t *this, chunk_t packet)
|
|||||||
/* we parse only v3 or v4 signature packets */
|
/* we parse only v3 or v4 signature packets */
|
||||||
if (version != 3 && version != 4)
|
if (version != 3 && version != 4)
|
||||||
{
|
{
|
||||||
DBG2(DBG_LIB, "L2 - v%d signature ignored", version);
|
DBG2(DBG_ASN, "L2 - v%d signature ignored", version);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
if (version == 4)
|
if (version == 4)
|
||||||
@@ -364,7 +364,7 @@ static bool parse_signature(private_pgp_cert_t *this, chunk_t packet)
|
|||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
DBG2(DBG_LIB, "L2 - v%d signature of type 0x%02x", version, type);
|
DBG2(DBG_ASN, "L2 - v%d signature of type 0x%02x", version, type);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -377,7 +377,7 @@ static bool parse_signature(private_pgp_cert_t *this, chunk_t packet)
|
|||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
DBG2(DBG_LIB, "L2 - v3 signature of type 0x%02x, created %T", type,
|
DBG2(DBG_ASN, "L2 - v3 signature of type 0x%02x, created %T", type,
|
||||||
&created, FALSE);
|
&created, FALSE);
|
||||||
}
|
}
|
||||||
/* TODO: parse and save signature to a list */
|
/* TODO: parse and save signature to a list */
|
||||||
@@ -391,7 +391,7 @@ static bool parse_user_id(private_pgp_cert_t *this, chunk_t packet)
|
|||||||
{
|
{
|
||||||
DESTROY_IF(this->user_id);
|
DESTROY_IF(this->user_id);
|
||||||
this->user_id = identification_create_from_encoding(ID_KEY_ID, packet);
|
this->user_id = identification_create_from_encoding(ID_KEY_ID, packet);
|
||||||
DBG2(DBG_LIB, "L2 - '%Y'", this->user_id);
|
DBG2(DBG_ASN, "L2 - '%Y'", this->user_id);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ bool pgp_read_scalar(chunk_t *blob, size_t bytes, u_int32_t *scalar)
|
|||||||
|
|
||||||
if (bytes > blob->len)
|
if (bytes > blob->len)
|
||||||
{
|
{
|
||||||
DBG1(DBG_LIB, "PGP data too short to read %d byte scalar", bytes);
|
DBG1(DBG_ASN, "PGP data too short to read %d byte scalar", bytes);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
while (bytes-- > 0)
|
while (bytes-- > 0)
|
||||||
@@ -100,13 +100,13 @@ bool pgp_read_mpi(chunk_t *blob, chunk_t *mpi)
|
|||||||
|
|
||||||
if (!pgp_read_scalar(blob, 2, &bits))
|
if (!pgp_read_scalar(blob, 2, &bits))
|
||||||
{
|
{
|
||||||
DBG1(DBG_LIB, "PGP data too short to read MPI length");
|
DBG1(DBG_ASN, "PGP data too short to read MPI length");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
bytes = (bits + 7) / 8;
|
bytes = (bits + 7) / 8;
|
||||||
if (bytes > blob->len)
|
if (bytes > blob->len)
|
||||||
{
|
{
|
||||||
DBG1(DBG_LIB, "PGP data too short to read %d byte MPI", bytes);
|
DBG1(DBG_ASN, "PGP data too short to read %d byte MPI", bytes);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
*mpi = chunk_create(blob->ptr, bytes);
|
*mpi = chunk_create(blob->ptr, bytes);
|
||||||
@@ -146,7 +146,7 @@ bool pgp_read_packet(chunk_t *blob, chunk_t *data, pgp_packet_tag_t *tag)
|
|||||||
|
|
||||||
if (!blob->len)
|
if (!blob->len)
|
||||||
{
|
{
|
||||||
DBG1(DBG_LIB, "missing input");
|
DBG1(DBG_ASN, "missing input");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
t = blob->ptr[0];
|
t = blob->ptr[0];
|
||||||
@@ -154,27 +154,27 @@ bool pgp_read_packet(chunk_t *blob, chunk_t *data, pgp_packet_tag_t *tag)
|
|||||||
/* bit 7 must be set */
|
/* bit 7 must be set */
|
||||||
if (!(t & 0x80))
|
if (!(t & 0x80))
|
||||||
{
|
{
|
||||||
DBG1(DBG_LIB, "invalid packet tag");
|
DBG1(DBG_ASN, "invalid packet tag");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
/* bit 6 set defines new packet format */
|
/* bit 6 set defines new packet format */
|
||||||
if (t & 0x40)
|
if (t & 0x40)
|
||||||
{
|
{
|
||||||
DBG1(DBG_LIB, "new PGP packet format not supported");
|
DBG1(DBG_ASN, "new PGP packet format not supported");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
t = (t & 0x3C) >> 2;
|
t = (t & 0x3C) >> 2;
|
||||||
if (!pgp_old_packet_length(blob, &len) || len > blob->len)
|
if (!pgp_old_packet_length(blob, &len) || len > blob->len)
|
||||||
{
|
{
|
||||||
DBG1(DBG_LIB, "invalid packet length");
|
DBG1(DBG_ASN, "invalid packet length");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
*data = chunk_create(blob->ptr, len);
|
*data = chunk_create(blob->ptr, len);
|
||||||
*blob = chunk_skip(*blob, len);
|
*blob = chunk_skip(*blob, len);
|
||||||
*tag = t;
|
*tag = t;
|
||||||
DBG2(DBG_LIB, "L1 - PGP %N (%u bytes)", pgp_packet_tag_names, t, len);
|
DBG2(DBG_ASN, "L1 - PGP %N (%u bytes)", pgp_packet_tag_names, t, len);
|
||||||
DBG3(DBG_LIB, "%B", data);
|
DBG3(DBG_ASN, "%B", data);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user