EVP_PKEY_set1_EC_KEY(key, eckey);
EC_KEY_free(eckey);
/* make sure digest matches */
- buffer_t *dgst = t_buffer_create(32);
+ buffer_t *digest = t_buffer_create(32);
struct dcrypt_public_key tmp;
i_zero(&tmp);
tmp.key = key;
- if (!dcrypt_openssl_public_key_id_old(&tmp, dgst, error_r)) {
+ if (!dcrypt_openssl_public_key_id_old(&tmp, digest, error_r)) {
EVP_PKEY_free(key);
return FALSE;
}
- if (strcmp(binary_to_hex(dgst->data, dgst->used),
+ if (strcmp(binary_to_hex(digest->data, digest->used),
input[len-1]) != 0) {
*error_r = "Key id mismatch after load";
EVP_PKEY_free(key);
}
/* make sure digest matches */
- buffer_t *dgst = t_buffer_create(32);
+ buffer_t *digest = t_buffer_create(32);
struct dcrypt_public_key tmpkey;
i_zero(&tmpkey);
tmpkey.key = pkey;
- if (!dcrypt_openssl_public_key_id(&tmpkey, "sha256", dgst, error_r)) {
+ if (!dcrypt_openssl_public_key_id(&tmpkey, "sha256", digest, error_r)) {
EVP_PKEY_free(pkey);
return FALSE;
}
- if (strcmp(binary_to_hex(dgst->data, dgst->used), input[len-1]) != 0) {
+ if (strcmp(binary_to_hex(digest->data, digest->used), input[len-1]) != 0) {
*error_r = "Key id mismatch after load";
EVP_PKEY_free(pkey);
return FALSE;
EC_GROUP_free(g);
i_assert(pkey != NULL);
/* make sure digest matches */
- buffer_t *dgst = t_buffer_create(32);
+ buffer_t *digest = t_buffer_create(32);
struct dcrypt_public_key tmp;
i_zero(&tmp);
tmp.key = pkey;
- if (!dcrypt_openssl_public_key_id_old(&tmp, dgst, error_r)) {
+ if (!dcrypt_openssl_public_key_id_old(&tmp, digest, error_r)) {
EVP_PKEY_free(pkey);
return FALSE;
}
- if (strcmp(binary_to_hex(dgst->data, dgst->used),
+ if (strcmp(binary_to_hex(digest->data, digest->used),
input[len-1]) != 0) {
*error_r = "Key id mismatch after load";
EVP_PKEY_free(pkey);
}
/* make sure digest matches */
- buffer_t *dgst = t_buffer_create(32);
+ buffer_t *digest = t_buffer_create(32);
struct dcrypt_public_key tmpkey = {
.key = pkey
};
- if (!dcrypt_openssl_public_key_id(&tmpkey, "sha256", dgst, error_r)) {
+ if (!dcrypt_openssl_public_key_id(&tmpkey, "sha256", digest, error_r)) {
EVP_PKEY_free(pkey);
return FALSE;
}
- if (strcmp(binary_to_hex(dgst->data, dgst->used), input[len-1]) != 0) {
+ if (strcmp(binary_to_hex(digest->data, digest->used), input[len-1]) != 0) {
*error_r = "Key id mismatch after load";
EVP_PKEY_free(pkey);
return FALSE;
enum dcrypt_key_type ktype;
int keys;
bool have_key = FALSE;
- unsigned char dgst[32];
+ unsigned char digest[32];
uint32_t val;
buffer_t buf;
/* if we have a key, prefab the digest */
if (stream->priv_key != NULL) {
- buffer_create_from_data(&buf, dgst, sizeof(dgst));
+ buffer_create_from_data(&buf, digest, sizeof(digest));
if (!dcrypt_key_id_private(stream->priv_key, "sha256", &buf,
&error)) {
io_stream_set_error(&stream->istream.iostream,
/* for each key */
for(;keys>0;keys--) {
- if ((size_t)(end-data) < 1 + (ssize_t)sizeof(dgst))
+ if ((size_t)(end-data) < 1 + (ssize_t)sizeof(digest))
return 0;
ktype = *data++;
if (stream->priv_key != NULL) {
/* see if key matches to the one we have */
- if (memcmp(dgst, data, sizeof(dgst)) == 0) {
+ if (memcmp(digest, data, sizeof(digest)) == 0) {
have_key = TRUE;
break;
}
} else if (stream->key_callback != NULL) {
const char *hexdgst = /* digest length */
- binary_to_hex(data, sizeof(dgst));
+ binary_to_hex(data, sizeof(digest));
if (stream->priv_key != NULL)
dcrypt_key_unref_private(&stream->priv_key);
/* hope you going to give us right key.. */
break;
}
}
- data += sizeof(dgst);
+ data += sizeof(digest);
/* wasn't correct key, skip over some data */
if (!get_msb32(&data, end, &val) ||
return -1;
}
- data += sizeof(dgst);
+ data += sizeof(digest);
const unsigned char *ephemeral_key;
uint32_t ep_key_len;
if ((dstream->flags & IO_STREAM_ENC_INTEGRITY_HMAC) ==
IO_STREAM_ENC_INTEGRITY_HMAC) {
size_t maclen = dcrypt_ctx_hmac_get_digest_length(dstream->ctx_mac);
- unsigned char dgst[maclen];
+ unsigned char digest[maclen];
buffer_t db;
- buffer_create_from_data(&db, dgst, sizeof(dgst));
+ buffer_create_from_data(&db, digest, sizeof(digest));
if (!dcrypt_ctx_hmac_final(dstream->ctx_mac, &db, &error)) {
io_stream_set_error(&stream->iostream,
"Cannot verify MAC: %s", error);
stream->istream.stream_errno = EIO;
return -1;
}
- if (memcmp(dgst, data + decrypt_size, maclen) != 0) {
+ if (memcmp(digest, data + decrypt_size, maclen) != 0) {
io_stream_set_error(&stream->iostream,
"Cannot verify MAC: mismatch");
stream->istream.stream_errno = EIO;
ssize_t siz;
const struct hash_method *hash = hash_method_lookup("sha256");
unsigned char hash_ctx[hash->context_size];
- unsigned char hash_dgst[hash->digest_size];
+ unsigned char hash_digest[hash->digest_size];
hash->init(hash_ctx);
test_begin("test_static_v1_input");
i_stream_unref(&is_4);
- hash->result(hash_ctx, hash_dgst);
+ hash->result(hash_ctx, hash_digest);
test_assert(strcmp(test_sample_v1_hash,
- binary_to_hex(hash_dgst, sizeof(hash_dgst))) == 0);
+ binary_to_hex(hash_digest, sizeof(hash_digest))) == 0);
test_end();
}
ssize_t siz;
const struct hash_method *hash = hash_method_lookup("sha256");
unsigned char hash_ctx[hash->context_size];
- unsigned char hash_dgst[hash->digest_size];
+ unsigned char hash_digest[hash->digest_size];
hash->init(hash_ctx);
test_begin("test_static_v1_input_short");
i_stream_unref(&is_4);
- hash->result(hash_ctx, hash_dgst);
+ hash->result(hash_ctx, hash_digest);
test_assert(strcmp(test_sample_v1_short_hash,
- binary_to_hex(hash_dgst, sizeof(hash_dgst))) == 0);
+ binary_to_hex(hash_digest, sizeof(hash_digest))) == 0);
test_end();
}
ssize_t amt;
const struct hash_method *hash = hash_method_lookup("sha256");
unsigned char hash_ctx[hash->context_size];
- unsigned char hash_dgst[hash->digest_size];
+ unsigned char hash_digest[hash->digest_size];
hash->init(hash_ctx);
struct istream *is_1 =
i_stream_unref(&is_4);
- hash->result(hash_ctx, hash_dgst);
+ hash->result(hash_ctx, hash_digest);
test_assert(strcmp(test_sample_v2_hash,
- binary_to_hex(hash_dgst, sizeof(hash_dgst))) == 0);
+ binary_to_hex(hash_digest, sizeof(hash_digest))) == 0);
test_end();
o_stream_close(os_2);
i_stream_close(is_2);
- hash->result(hash_ctx, hash_dgst);
- printf("%s\n", binary_to_hex(hash_dgst, sizeof(hash_dgst)));
+ hash->result(hash_ctx, hash_digest);
+ printf("%s\n", binary_to_hex(hash_digest, sizeof(hash_digest)));
*/
}