Sprinkle more hx509_context so we can return propper errors.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18863 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2006-10-24 13:48:18 +00:00
parent 43c1cc11e7
commit ff31485ed0

View File

@@ -172,7 +172,8 @@ try_decrypt(hx509_context context,
EVP_CIPHER_CTX_cleanup(&ctx); EVP_CIPHER_CTX_cleanup(&ctx);
} }
ret = _hx509_collector_private_key_add(collector, ret = _hx509_collector_private_key_add(context,
collector,
hx509_signature_rsa(), hx509_signature_rsa(),
NULL, NULL,
&clear, &clear,
@@ -207,14 +208,14 @@ parse_rsa_private_key(hx509_context context, struct hx509_collector *c,
lock = _hx509_collector_get_lock(c); lock = _hx509_collector_get_lock(c);
if (lock == NULL) { if (lock == NULL) {
hx509_set_error_string(context, 0, EINVAL, hx509_set_error_string(context, 0, HX509_ALG_NOT_SUPP,
"Failed to get password for " "Failed to get password for "
"password protected file"); "password protected file");
return EINVAL; return EINVAL;
} }
if (strcmp(enc, "4,ENCRYPTED") != 0) { if (strcmp(enc, "4,ENCRYPTED") != 0) {
hx509_set_error_string(context, 0, EINVAL, hx509_set_error_string(context, 0, HX509_PARSING_KEY_FAILED,
"RSA key encrypted in unknown method %s", "RSA key encrypted in unknown method %s",
enc); enc);
hx509_clear_error_string(context); hx509_clear_error_string(context);
@@ -223,7 +224,7 @@ parse_rsa_private_key(hx509_context context, struct hx509_collector *c,
dek = find_header(headers, "DEK-Info"); dek = find_header(headers, "DEK-Info");
if (dek == NULL) { if (dek == NULL) {
hx509_set_error_string(context, 0, EINVAL, hx509_set_error_string(context, 0, HX509_PARSING_KEY_FAILED,
"Encrypted RSA missing DEK-Info"); "Encrypted RSA missing DEK-Info");
return EINVAL; return EINVAL;
} }
@@ -249,7 +250,7 @@ parse_rsa_private_key(hx509_context context, struct hx509_collector *c,
cipher = EVP_get_cipherbyname(type); cipher = EVP_get_cipherbyname(type);
if (cipher == NULL) { if (cipher == NULL) {
free(ivdata); free(ivdata);
hx509_set_error_string(context, 0, EINVAL, hx509_set_error_string(context, 0, HX509_ALG_NOT_SUPP,
"RSA key encrypted with " "RSA key encrypted with "
"unsupported cipher: %s", "unsupported cipher: %s",
type); type);
@@ -266,9 +267,9 @@ parse_rsa_private_key(hx509_context context, struct hx509_collector *c,
if (ssize < 0 || ssize < PKCS5_SALT_LEN || ssize < EVP_CIPHER_iv_length(cipher)) { if (ssize < 0 || ssize < PKCS5_SALT_LEN || ssize < EVP_CIPHER_iv_length(cipher)) {
free(ivdata); free(ivdata);
hx509_set_error_string(context, 0, EINVAL, hx509_set_error_string(context, 0, HX509_PARSING_KEY_FAILED,
"Salt have wrong length in RSA key file"); "Salt have wrong length in RSA key file");
return EINVAL; return HX509_PARSING_KEY_FAILED;
} }
pw = _hx509_lock_get_passwords(lock); pw = _hx509_lock_get_passwords(lock);
@@ -316,7 +317,8 @@ parse_rsa_private_key(hx509_context context, struct hx509_collector *c,
keydata.data = rk_UNCONST(data); keydata.data = rk_UNCONST(data);
keydata.length = len; keydata.length = len;
ret = _hx509_collector_private_key_add(c, ret = _hx509_collector_private_key_add(context,
c,
hx509_signature_rsa(), hx509_signature_rsa(),
NULL, NULL,
&keydata, &keydata,
@@ -466,9 +468,9 @@ parse_pem_file(hx509_context context,
fclose(f); fclose(f);
if (where != BEFORE) { if (where != BEFORE) {
hx509_set_error_string(context, 0, EINVAL, hx509_set_error_string(context, 0, HX509_PARSING_KEY_FAILED,
"File ends before end of PEM end tag"); "File ends before end of PEM end tag");
ret = EINVAL; ret = HX509_PARSING_KEY_FAILED;
} }
if (data) if (data)
free(data); free(data);