X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;ds=sidebyside;f=ccan%2Fcrypto%2Fsha256%2Fsha256.h;h=d8b683ecee3747a2081592a8e0b624e3c2b8d98e;hb=86769a9aa665c83204f397af95d01d17973bf763;hp=812091a3283069282beaaee03e6098053523fec6;hpb=0d73f8ebb66d2613ecc0b87c6e608de59be110f6;p=ccan diff --git a/ccan/crypto/sha256/sha256.h b/ccan/crypto/sha256/sha256.h index 812091a3..d8b683ec 100644 --- a/ccan/crypto/sha256/sha256.h +++ b/ccan/crypto/sha256/sha256.h @@ -6,7 +6,7 @@ #include /* Uncomment this to use openssl's SHA256 routines (and link with -lcrypto) */ -//#define CCAN_CRYPTO_SHA256_USE_OPENSSL 1 +/*#define CCAN_CRYPTO_SHA256_USE_OPENSSL 1*/ #ifdef CCAN_CRYPTO_SHA256_USE_OPENSSL #include @@ -29,15 +29,15 @@ struct sha256 { }; /** - * sha256 - return sha256 of an array of bytes. + * sha256 - return sha256 of an object. * @sha256: the sha256 to fill in - * @p: array or pointer to first element - * @num: the number of elements to hash + * @p: pointer to memory, + * @size: the number of bytes pointed to by @p * - * The bytes pointed to by @p is SHA256 hashes into @sha256. This is + * The bytes pointed to by @p is SHA256 hashed into @sha256. This is * equivalent to sha256_init(), sha256_update() then sha256_done(). */ -#define sha256(sha256, p, num) sha256_arr((sha256), (p), (num), sizeof(*(p))) +void sha256(struct sha256 *sha, const void *p, size_t size); /** * struct sha256_ctx - structure to store running context for sha256 @@ -82,7 +82,7 @@ void sha256_init(struct sha256_ctx *ctx); /** * SHA256_INIT - initializer for an SHA256 context. * - * This can be used to staticly initialize an SHA256 context (instead + * This can be used to statically initialize an SHA256 context (instead * of sha256_init()). * * Example: @@ -110,16 +110,15 @@ void sha256_init(struct sha256_ctx *ctx); #endif /** - * sha256_update - include an array of data in the hash. + * sha256_update - include some memory in the hash. * @ctx: the sha256_ctx to use - * @p: array or pointer to first element - * @num: the number of elements to hash + * @p: pointer to memory, + * @size: the number of bytes pointed to by @p * * You can call this multiple times to hash more data, before calling * sha256_done(). */ -#define sha256_update(ctx, p, num) \ - sha256_update_arr((ctx), (p), (num), sizeof(*(p))) +void sha256_update(struct sha256_ctx *ctx, const void *p, size_t size); /** * sha256_done - finish SHA256 and return the hash @@ -146,8 +145,4 @@ void sha256_le64(struct sha256_ctx *ctx, uint64_t v); void sha256_be16(struct sha256_ctx *ctx, uint16_t v); void sha256_be32(struct sha256_ctx *ctx, uint32_t v); void sha256_be64(struct sha256_ctx *ctx, uint64_t v); - -void sha256_update_arr(struct sha256_ctx *ctx, const void *p, - size_t num, size_t size); -void sha256_arr(struct sha256 *sha, const void *p, size_t num, size_t size); #endif /* CCAN_CRYPTO_SHA256_H */