cleanup:
gnutls_free(buf);
if (ret < 0) {
- gnutls_free(plaintext->data);
_gnutls_switch_fips_state(GNUTLS_FIPS140_OP_ERROR);
} else if (not_approved) {
_gnutls_switch_fips_state(GNUTLS_FIPS140_OP_NOT_APPROVED);
gnutls_pubkey_t pubkey;
gnutls_datum_t ciphertext = { NULL, 0 };
gnutls_datum_t decrypted = { NULL, 0 };
+ gnutls_datum_t uninitialized;
assert(gnutls_pubkey_init(&pubkey) >= 0);
ret = gnutls_pubkey_import_privkey(pubkey, privkey, 0, 0);
ret = gnutls_privkey_decrypt_data(privkey, 0, &ciphertext, &decrypted);
fips_pop_context(fips_context, exp_state);
+ /* gnutls_privkey_decrypt_data shouldn't touch plaintext upon
+ * failure */
+ assert(ciphertext.size >= 4);
+ memcpy(ciphertext.data, "\xde\xad\xbe\xef", 4);
+ ret = gnutls_privkey_decrypt_data(privkey, 0, &ciphertext,
+ &uninitialized);
+ if (ret >= 0)
+ fail("gnutls_privkey_decrypt_data unexpectedly succeeded\n");
+
out:
gnutls_pubkey_deinit(pubkey);
gnutls_free(ciphertext.data);