X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=openssl.c;h=9d3ad577da4f5636f409fbacb0f1433ca0c720e1;hb=2391dbc88e15dd54207f289bb4fdbaf0e801b1ca;hp=0ad9d7db4e7f035dce140365b2b38abc144b6923;hpb=267c322e02364c331f523ce16bdadb46fd3449f8;p=paraslash.git diff --git a/openssl.c b/openssl.c index 0ad9d7db..9d3ad577 100644 --- a/openssl.c +++ b/openssl.c @@ -283,7 +283,7 @@ int apc_get_pubkey(const char *key_file, struct asymmetric_key **result) unsigned char *blob; size_t decoded_size; int ret; - struct asymmetric_key *key = para_malloc(sizeof(*key)); + struct asymmetric_key *key = alloc(sizeof(*key)); ret = decode_public_key(key_file, &blob, &decoded_size); if (ret < 0) @@ -324,7 +324,7 @@ int apc_priv_decrypt(const char *key_file, unsigned char *outbuf, return ret; if (inlen < 0) return -E_RSA; - priv = para_malloc(sizeof(*priv)); + priv = alloc(sizeof(*priv)); ret = get_private_key(key_file, &priv->rsa); if (ret < 0) { free(priv); @@ -366,7 +366,7 @@ struct stream_cipher { struct stream_cipher *sc_new(const unsigned char *data, int len) { - struct stream_cipher *sc = para_malloc(sizeof(*sc)); + struct stream_cipher *sc = alloc(sizeof(*sc)); assert(len >= 2 * AES_CRT128_BLOCK_SIZE); sc->aes = EVP_CIPHER_CTX_new(); @@ -390,7 +390,7 @@ static void aes_ctr128_crypt(EVP_CIPHER_CTX *ctx, struct iovec *src, *dst = (typeof(*dst)) { /* Add one for the terminating zero byte. */ - .iov_base = para_malloc(inlen + 1), + .iov_base = alloc(inlen + 1), .iov_len = inlen }; ret = EVP_EncryptUpdate(ctx, dst->iov_base, &outlen, src->iov_base, inlen); @@ -414,3 +414,11 @@ void hash_function(const char *data, unsigned long len, unsigned char *hash) SHA1_Update(&c, data, len); SHA1_Final(hash, &c); } + +void hash2_function(const char *data, unsigned long len, unsigned char *hash) +{ + SHA256_CTX c; + SHA256_Init(&c); + SHA256_Update(&c, data, len); + SHA256_Final(hash, &c); +}