Adding DBG_LIB to all calls of libstrongswan's version of DBG*.

This commit is contained in:
Tobias Brunner
2010-04-06 12:47:40 +02:00
parent 9ed6341d3f
commit 8b0e09103b
82 changed files with 660 additions and 576 deletions
+1 -1
View File
@@ -686,7 +686,7 @@ static void add_test_vector(private_crypto_factory_t *this,
case RANDOM_NUMBER_GENERATOR:
return this->tester->add_rng_vector(this->tester, vector);
default:
DBG1("%N test vectors not supported, ignored",
DBG1(DBG_LIB, "%N test vectors not supported, ignored",
transform_type_names, type);
}
}
+20 -20
View File
@@ -136,7 +136,7 @@ static bool test_crypter(private_crypto_tester_t *this,
crypter->destroy(crypter);
if (failed)
{
DBG1("disabled %N: test vector %u failed",
DBG1(DBG_LIB, "disabled %N: test vector %u failed",
encryption_algorithm_names, alg, tested);
break;
}
@@ -144,14 +144,14 @@ static bool test_crypter(private_crypto_tester_t *this,
enumerator->destroy(enumerator);
if (!tested)
{
DBG1("%s %N: no test vectors found",
DBG1(DBG_LIB, "%s %N: no test vectors found",
this->required ? "disabled" : "enabled ",
encryption_algorithm_names, alg);
return !this->required;
}
if (!failed)
{
DBG1("enabled %N: passed %u test vectors",
DBG1(DBG_LIB, "enabled %N: passed %u test vectors",
encryption_algorithm_names, alg, tested);
}
return !failed;
@@ -183,7 +183,7 @@ static bool test_signer(private_crypto_tester_t *this,
signer = create(alg);
if (!signer)
{
DBG1("disabled %N: creating instance failed",
DBG1(DBG_LIB, "disabled %N: creating instance failed",
integrity_algorithm_names, alg);
failed = TRUE;
break;
@@ -240,7 +240,7 @@ static bool test_signer(private_crypto_tester_t *this,
signer->destroy(signer);
if (failed)
{
DBG1("disabled %N: test vector %u failed",
DBG1(DBG_LIB, "disabled %N: test vector %u failed",
integrity_algorithm_names, alg, tested);
break;
}
@@ -248,14 +248,14 @@ static bool test_signer(private_crypto_tester_t *this,
enumerator->destroy(enumerator);
if (!tested)
{
DBG1("%s %N: no test vectors found",
DBG1(DBG_LIB, "%s %N: no test vectors found",
this->required ? "disabled" : "enabled ",
integrity_algorithm_names, alg);
return !this->required;
}
if (!failed)
{
DBG1("enabled %N: passed %u test vectors",
DBG1(DBG_LIB, "enabled %N: passed %u test vectors",
integrity_algorithm_names, alg, tested);
}
return !failed;
@@ -287,7 +287,7 @@ static bool test_hasher(private_crypto_tester_t *this, hash_algorithm_t alg,
hasher = create(alg);
if (!hasher)
{
DBG1("disabled %N: creating instance failed",
DBG1(DBG_LIB, "disabled %N: creating instance failed",
hash_algorithm_names, alg);
failed = TRUE;
break;
@@ -330,7 +330,7 @@ static bool test_hasher(private_crypto_tester_t *this, hash_algorithm_t alg,
hasher->destroy(hasher);
if (failed)
{
DBG1("disabled %N: test vector %u failed",
DBG1(DBG_LIB, "disabled %N: test vector %u failed",
hash_algorithm_names, alg, tested);
break;
}
@@ -338,14 +338,14 @@ static bool test_hasher(private_crypto_tester_t *this, hash_algorithm_t alg,
enumerator->destroy(enumerator);
if (!tested)
{
DBG1("%s %N: no test vectors found",
DBG1(DBG_LIB, "%s %N: no test vectors found",
this->required ? "disabled" : "enabled ",
hash_algorithm_names, alg);
return !this->required;
}
if (!failed)
{
DBG1("enabled %N: passed %u test vectors",
DBG1(DBG_LIB, "enabled %N: passed %u test vectors",
hash_algorithm_names, alg, tested);
}
return !failed;
@@ -377,7 +377,7 @@ static bool test_prf(private_crypto_tester_t *this,
prf = create(alg);
if (!prf)
{
DBG1("disabled %N: creating instance failed",
DBG1(DBG_LIB, "disabled %N: creating instance failed",
pseudo_random_function_names, alg);
failed = TRUE;
break;
@@ -431,7 +431,7 @@ static bool test_prf(private_crypto_tester_t *this,
prf->destroy(prf);
if (failed)
{
DBG1("disabled %N: test vector %u failed",
DBG1(DBG_LIB, "disabled %N: test vector %u failed",
pseudo_random_function_names, alg, tested);
break;
}
@@ -439,14 +439,14 @@ static bool test_prf(private_crypto_tester_t *this,
enumerator->destroy(enumerator);
if (!tested)
{
DBG1("%s %N: no test vectors found",
DBG1(DBG_LIB, "%s %N: no test vectors found",
this->required ? "disabled" : "enabled ",
pseudo_random_function_names, alg);
return !this->required;
}
if (!failed)
{
DBG1("enabled %N: passed %u test vectors",
DBG1(DBG_LIB, "enabled %N: passed %u test vectors",
pseudo_random_function_names, alg, tested);
}
return !failed;
@@ -465,7 +465,7 @@ static bool test_rng(private_crypto_tester_t *this, rng_quality_t quality,
if (!this->rng_true && quality == RNG_TRUE)
{
DBG1("enabled %N: skipping test (disabled by config)",
DBG1(DBG_LIB, "enabled %N: skipping test (disabled by config)",
rng_quality_names, quality);
return TRUE;
}
@@ -485,7 +485,7 @@ static bool test_rng(private_crypto_tester_t *this, rng_quality_t quality,
rng = create(quality);
if (!rng)
{
DBG1("disabled %N: creating instance failed",
DBG1(DBG_LIB, "disabled %N: creating instance failed",
rng_quality_names, quality);
failed = TRUE;
break;
@@ -515,7 +515,7 @@ static bool test_rng(private_crypto_tester_t *this, rng_quality_t quality,
rng->destroy(rng);
if (failed)
{
DBG1("disabled %N: test vector %u failed",
DBG1(DBG_LIB, "disabled %N: test vector %u failed",
rng_quality_names, quality, tested);
break;
}
@@ -523,14 +523,14 @@ static bool test_rng(private_crypto_tester_t *this, rng_quality_t quality,
enumerator->destroy(enumerator);
if (!tested)
{
DBG1("%s %N: no test vectors found",
DBG1(DBG_LIB, "%s %N: no test vectors found",
this->required ? ", disabled" : "enabled ",
rng_quality_names, quality);
return !this->required;
}
if (!failed)
{
DBG1("enabled %N: passed %u test vectors",
DBG1(DBG_LIB, "enabled %N: passed %u test vectors",
rng_quality_names, quality, tested);
}
return !failed;
+41 -41
View File
@@ -152,13 +152,13 @@ static bool abort_parsing(private_pkcs7_t *this, int type)
{
if (this->type != type)
{
DBG1("pkcs7 content to be parsed is not of type '%s'",
DBG1(DBG_LIB, "pkcs7 content to be parsed is not of type '%s'",
oid_names[type]);
return TRUE;
}
if (this->parsed)
{
DBG1("pkcs7 content has already been parsed");
DBG1(DBG_LIB, "pkcs7 content has already been parsed");
return TRUE;
}
this->parsed = TRUE;
@@ -301,14 +301,14 @@ static bool parse_signedData(private_pkcs7_t *this, x509_t *cacert)
}
case PKCS7_SIGNER_INFO:
signerInfos++;
DBG2(" signer #%d", signerInfos);
DBG2(DBG_LIB, " signer #%d", signerInfos);
break;
case PKCS7_SIGNED_ISSUER:
{
identification_t *issuer;
issuer = identification_create_from_encoding(ID_DER_ASN1_DN, object);
DBG2(" '%Y'", issuer);
DBG2(DBG_LIB, " '%Y'", issuer);
issuer->destroy(issuer);
break;
}
@@ -344,33 +344,33 @@ end:
if (signerInfos == 0)
{
DBG1("no signerInfo object found");
DBG1(DBG_LIB, "no signerInfo object found");
return FALSE;
}
else if (signerInfos > 1)
{
DBG1("more than one signerInfo object found");
DBG1(DBG_LIB, "more than one signerInfo object found");
return FALSE;
}
if (this->attributes == NULL)
{
DBG1("no authenticatedAttributes object found");
DBG1(DBG_LIB, "no authenticatedAttributes object found");
return FALSE;
}
if (enc_alg != OID_RSA_ENCRYPTION)
{
DBG1("only RSA digest encryption supported");
DBG1(DBG_LIB, "only RSA digest encryption supported");
return FALSE;
}
if (signer->verify_emsa_pkcs1_signature(signer, algorithm,
this->attributes->get_encoding(this->attributes), encrypted_digest) != SUCCESS)
{
DBG1("invalid digest signature");
DBG1(DBG_LIB, "invalid digest signature");
return FALSE;
}
else
{
DBG2("digest signature is valid");
DBG2(DBG_LIB, "digest signature is valid");
}
if (this->data.ptr != NULL)
{
@@ -378,7 +378,7 @@ end:
if (messageDigest.ptr == NULL)
{
DBG1("messageDigest attribute not found");
DBG1(DBG_LIB, "messageDigest attribute not found");
return FALSE;
}
else
@@ -390,25 +390,25 @@ end:
hasher = lib->crypto->create_hasher(lib->crypto, algorithm)
if (hasher == NULL)
{
DBG1("hash algorithm %N not supported",
DBG1(DBG_LIB, "hash algorithm %N not supported",
hash_algorithm_names, algorithm);
free(messageDigest.ptr);
return FALSE;
}
hasher->allocate_hash(hasher, this->data, &hash);
hasher->destroy(hasher);
DBG3("hash: %B", &hash);
DBG3(DBG_LIB, "hash: %B", &hash);
valid = chunk_equals(messageDigest, hash);
free(messageDigest.ptr);
free(hash.ptr);
if (valid)
{
DBG2("messageDigest is valid");
DBG2(DBG_LIB, "messageDigest is valid");
}
else
{
DBG1("invalid messageDigest");
DBG1(DBG_LIB, "invalid messageDigest");
return FALSE;
}
}
@@ -480,14 +480,14 @@ static bool parse_envelopedData(private_pkcs7_t *this, chunk_t serialNumber,
case PKCS7_ENVELOPED_VERSION:
if (*object.ptr != 0)
{
DBG1("envelopedData version is not 0");
DBG1(DBG_LIB, "envelopedData version is not 0");
goto end;
}
break;
case PKCS7_RECIPIENT_INFO_VERSION:
if (*object.ptr != 0)
{
DBG1("recipient info version is not 0");
DBG1(DBG_LIB, "recipient info version is not 0");
goto end;
}
break;
@@ -496,14 +496,14 @@ static bool parse_envelopedData(private_pkcs7_t *this, chunk_t serialNumber,
identification_t *issuer;
issuer = identification_create_from_encoding(ID_DER_ASN1_DN, object);
DBG2(" '%Y'", issuer);
DBG2(DBG_LIB, " '%Y'", issuer);
issuer->destroy(issuer);
}
break;
case PKCS7_SERIAL_NUMBER:
if (!chunk_equals(serialNumber, object))
{
DBG1("serial numbers do not match");
DBG1(DBG_LIB, "serial numbers do not match");
goto end;
}
break;
@@ -513,7 +513,7 @@ static bool parse_envelopedData(private_pkcs7_t *this, chunk_t serialNumber,
if (alg != OID_RSA_ENCRYPTION)
{
DBG1("only rsa encryption supported");
DBG1(DBG_LIB, "only rsa encryption supported");
goto end;
}
}
@@ -521,15 +521,15 @@ static bool parse_envelopedData(private_pkcs7_t *this, chunk_t serialNumber,
case PKCS7_ENCRYPTED_KEY:
if (key->pkcs1_decrypt(key, object, &symmetric_key) != SUCCESS)
{
DBG1("symmetric key could not be decrypted with rsa");
DBG1(DBG_LIB, "symmetric key could not be decrypted with rsa");
goto end;
}
DBG4("symmetric key : %B", &symmetric_key);
DBG4(DBG_LIB, "symmetric key : %B", &symmetric_key);
break;
case PKCS7_CONTENT_TYPE:
if (known_oid(object) != OID_PKCS7_DATA)
{
DBG1("encrypted content not of type pkcs7 data");
DBG1(DBG_LIB, "encrypted content not of type pkcs7 data");
goto end;
}
break;
@@ -546,22 +546,22 @@ static bool parse_envelopedData(private_pkcs7_t *this, chunk_t serialNumber,
crypter = crypter_create(ENCR_3DES, 0);
break;
default:
DBG1("Only DES and 3DES supported for symmetric encryption");
DBG1(DBG_LIB, "Only DES and 3DES supported for symmetric encryption");
goto end;
}
if (symmetric_key.len != crypter->get_key_size(crypter))
{
DBG1("symmetric key has wrong length");
DBG1(DBG_LIB, "symmetric key has wrong length");
goto end;
}
if (!parse_asn1_simple_object(&iv, ASN1_OCTET_STRING, level+1, "IV"))
{
DBG1("IV could not be parsed");
DBG1(DBG_LIB, "IV could not be parsed");
goto end;
}
if (iv.len != crypter->get_block_size(crypter))
{
DBG1("IV has wrong length");
DBG1(DBG_LIB, "IV has wrong length");
goto end;
}
}
@@ -583,7 +583,7 @@ end:
/* decrypt the content */
crypter->set_key(crypter, symmetric_key);
crypter->decrypt(crypter, encrypted_content, iv, &this->data);
DBG3("decrypted content with padding: %B", &this->data);
DBG3(DBG_LIB, "decrypted content with padding: %B", &this->data);
/* remove the padding */
{
@@ -593,7 +593,7 @@ end:
if (padding > this->data.len)
{
DBG1("padding greater than data length");
DBG1(DBG_LIB, "padding greater than data length");
goto failed;
}
this->data.len -= padding;
@@ -602,7 +602,7 @@ end:
{
if (*pos-- != pattern)
{
DBG1("wrong padding pattern");
DBG1(DBG_LIB, "wrong padding pattern");
goto failed;
}
}
@@ -656,7 +656,7 @@ static chunk_t get_contentInfo(private_pkcs7_t *this)
break;
case OID_UNKNOWN:
default:
DBG1("invalid pkcs7 contentInfo type");
DBG1(DBG_LIB, "invalid pkcs7 contentInfo type");
return chunk_empty;
}
@@ -727,7 +727,7 @@ bool build_envelopedData(private_pkcs7_t *this, x509_t *cert,
alg_oid = ASN1_3des_ede_cbc_oid;
break;
default:
DBG1(" encryption algorithm %N not supported",
DBG1(DBG_LIB, " encryption algorithm %N not supported",
encryption_algorithm_names, alg);
return FALSE;
}
@@ -735,7 +735,7 @@ bool build_envelopedData(private_pkcs7_t *this, x509_t *cert,
crypter = crypter_create(alg, 0);
if (crypter == NULL)
{
DBG1(" could not create crypter for algorithm %N",
DBG1(DBG_LIB, " could not create crypter for algorithm %N",
encryption_algorithm_names, alg);
return FALSE;
}
@@ -748,12 +748,12 @@ bool build_envelopedData(private_pkcs7_t *this, x509_t *cert,
rng = lib->crypto->create_rng(lib->crypto, RNG_TRUE);
rng->allocate_bytes(rng, crypter->get_key_size(crypter), &symmetricKey);
DBG4(" symmetric encryption key: %B", &symmetricKey);
DBG4(DBG_LIB, " symmetric encryption key: %B", &symmetricKey);
rng->destroy(rng);
rng = lib->crypto->create_rng(lib->crypto, RNG_WEAK);
rng->allocate_bytes(rng, crypter->get_block_size(crypter), &iv);
DBG4(" initialization vector: %B", &iv);
DBG4(DBG_LIB, " initialization vector: %B", &iv);
rng->destroy(rng);
}
@@ -767,7 +767,7 @@ bool build_envelopedData(private_pkcs7_t *this, x509_t *cert,
in.len = this->data.len + padding;
in.ptr = malloc(in.len);
DBG2(" padding %d bytes of data to multiple block size of %d bytes",
DBG2(DBG_LIB, " padding %d bytes of data to multiple block size of %d bytes",
(int)this->data.len, (int)in.len);
/* copy data */
@@ -775,14 +775,14 @@ bool build_envelopedData(private_pkcs7_t *this, x509_t *cert,
/* append padding */
memset(in.ptr + this->data.len, padding, padding);
}
DBG3(" padded unencrypted data: %B", &in);
DBG3(DBG_LIB, " padded unencrypted data: %B", &in);
/* symmetric encryption of data object */
crypter->set_key(crypter, symmetricKey);
crypter->encrypt(crypter, in, iv, &out);
crypter->destroy(crypter);
chunk_clear(&in);
DBG3(" encrypted data: %B", &out);
DBG3(DBG_LIB, " encrypted data: %B", &out);
/* build pkcs7 enveloped data object */
{
@@ -834,7 +834,7 @@ bool build_signedData(private_pkcs7_t *this, rsa_private_key_t *private_key,
if (this->certs->get_first(this->certs, (void**)&cert) != SUCCESS)
{
DBG1(" no pkcs7 signer certificate found");
DBG1(DBG_LIB, " no pkcs7 signer certificate found");
return FALSE;
}
@@ -847,7 +847,7 @@ bool build_signedData(private_pkcs7_t *this, rsa_private_key_t *private_key,
hasher = lib->crypto->create_hasher(lib->crypto, alg);
if (hasher == NULL)
{
DBG1(" hash algorithm %N not support",
DBG1(DBG_LIB, " hash algorithm %N not support",
hash_algorithm_names, alg);
return FALSE;
}
@@ -963,7 +963,7 @@ static bool parse_contentInfo(chunk_t blob, u_int level0, private_pkcs7_t *cInfo
if (cInfo->type < OID_PKCS7_DATA
|| cInfo->type > OID_PKCS7_ENCRYPTED_DATA)
{
DBG1("unknown pkcs7 content type");
DBG1(DBG_LIB, "unknown pkcs7 content type");
goto end;
}
}