(void)rounds; /* UNUSED */
(void)derived_key; /* UNUSED */
(void)derived_key_len; /* UNUSED */
- return -1; /* UNSUPPORTED */
+ return CRYPTOR_STUB_FUNCTION; /* UNSUPPORTED */
}
#endif
(void)ctx; /* UNUSED */
(void)key; /* UNUSED */
(void)key_len; /* UNUSED */
- return -1;
+ return CRYPTOR_STUB_FUNCTION;
}
static int
aes_ctr_encrypt_counter(archive_crypto_ctx *ctx)
{
(void)ctx; /* UNUSED */
- return -1;
+ return CRYPTOR_STUB_FUNCTION;
}
static int
(void)out; /* UNUSED */
(void)out_len; /* UNUSED */
aes_ctr_encrypt_counter(ctx); /* UNUSED */ /* Fix unused function warning */
- return -1;
+ return CRYPTOR_STUB_FUNCTION;
}
#else
#define archive_encrypto_aes_ctr_release(ctx) \
__archive_cryptor.encrypto_aes_ctr_release(ctx)
+/* Stub return value if no encryption support exists. */
+#define CRYPTOR_STUB_FUNCTION -2
+
/* Minimal interface to cryptographic functionality for internal use in
* libarchive */
struct archive_cryptor
p, salt_len, 1000, derived_key, key_len * 2 + 2);
if (r != 0) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Decryption is unsupported due to lack of "
- "crypto library");
+ r == CRYPTOR_STUB_FUNCTION ? "Decryption is unsupported due "
+ "to lack of crypto library" : "Failed to process passphrase");
return (ARCHIVE_FAILED);
}
"Can't generate random number for encryption");
return (ARCHIVE_FATAL);
}
- archive_pbkdf2_sha1(passphrase, strlen(passphrase),
+ ret = archive_pbkdf2_sha1(passphrase, strlen(passphrase),
salt, salt_len, 1000, derived_key, key_len * 2 + 2);
+ if (ret != 0) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ ret == CRYPTOR_STUB_FUNCTION ? "Encryption is unsupported due to "
+ "lack of crypto library" : "Failed to process passphrase");
+ return (ARCHIVE_FAILED);
+ }
ret = archive_encrypto_aes_ctr_init(&zip->cctx, derived_key, key_len);
if (ret != 0) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Decryption is unsupported due to lack of crypto library");
+ "Failed to initialize AES CTR mode");
return (ARCHIVE_FAILED);
}
ret = archive_hmac_sha1_init(&zip->hctx, derived_key + key_len,