summaryrefslogtreecommitdiff
path: root/src/rexmpp_digest.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/rexmpp_digest.h')
-rw-r--r--src/rexmpp_digest.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/rexmpp_digest.h b/src/rexmpp_digest.h
index 77f198a..5001e12 100644
--- a/src/rexmpp_digest.h
+++ b/src/rexmpp_digest.h
@@ -31,14 +31,55 @@ typedef struct rexmpp_digest rexmpp_digest_t;
typedef EVP_MD_CTX* rexmpp_digest_t;
#endif
+/**
+ @brief Finds the digest length for a given algorithm.
+ @param[in] algo An algorithm.
+ @returns Digest length in bytes.
+*/
size_t rexmpp_digest_len (rexmpp_digest_algorithm algo);
+
+/**
+ @brief Computes a digest for a buffer.
+ @param[in] algo An algorithm.
+ @param[in] in Input data.
+ @param[in] in_len Input data length.
+ @param[out] out Output buffer.
+ @param[in] out_len Output buffer length.
+ @returns 0 on success, non-zero on failure.
+*/
int rexmpp_digest_buffer (rexmpp_digest_algorithm algo,
const void *in,
size_t in_len,
void *out,
size_t out_len);
+
+/**
+ @brief Initializes a digest context.
+ @param[out] ctx Pointer to an allocated ::rexmpp_digest_t context
+ to initialize.
+ @param[in] algo An algorithm to use.
+ @returns 0 on success, non-zero on failure.
+*/
int rexmpp_digest_init (rexmpp_digest_t *ctx, rexmpp_digest_algorithm algo);
+
+/**
+ @brief Updates a digest computation.
+ @param[in,out] ctx Context pointer.
+ @param[in] in Input data.
+ @param[in] len Length of the input buffer.
+ @returns 0 on success, non-zero on failure.
+*/
int rexmpp_digest_update (rexmpp_digest_t *ctx, const void *in, size_t len);
+
+/**
+ @brief Finishes a digest computation, freeing the context and
+ providing the output.
+ @param[in,out] ctx Context pointer.
+ @param[out] out A place to write the computed digest into, can be
+ NULL to just free the context.
+ @param[in] len Length of the allocated output buffer.
+ @returns 0 on success, non-zero on failure.
+*/
int rexmpp_digest_finish (rexmpp_digest_t *ctx, void *out, size_t len);
#endif