Deleted Added
full compact
digest.h (261320) digest.h (263970)
1/* $OpenBSD: digest.h,v 1.1 2014/01/09 23:20:00 djm Exp $ */
1/* $OpenBSD: digest.h,v 1.2 2014/01/27 18:58:14 markus Exp $ */
2/*
3 * Copyright (c) 2013 Damien Miller <djm@mindrot.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES

--- 15 unchanged lines hidden (view full) ---

25#define SSH_DIGEST_MD5 0
26#define SSH_DIGEST_RIPEMD160 1
27#define SSH_DIGEST_SHA1 2
28#define SSH_DIGEST_SHA256 3
29#define SSH_DIGEST_SHA384 4
30#define SSH_DIGEST_SHA512 5
31#define SSH_DIGEST_MAX 6
32
2/*
3 * Copyright (c) 2013 Damien Miller <djm@mindrot.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES

--- 15 unchanged lines hidden (view full) ---

25#define SSH_DIGEST_MD5 0
26#define SSH_DIGEST_RIPEMD160 1
27#define SSH_DIGEST_SHA1 2
28#define SSH_DIGEST_SHA256 3
29#define SSH_DIGEST_SHA384 4
30#define SSH_DIGEST_SHA512 5
31#define SSH_DIGEST_MAX 6
32
33struct ssh_digest_ctx;
34
33/* Returns the algorithm's digest length in bytes or 0 for invalid algorithm */
34size_t ssh_digest_bytes(int alg);
35
35/* Returns the algorithm's digest length in bytes or 0 for invalid algorithm */
36size_t ssh_digest_bytes(int alg);
37
38/* Returns the block size of the digest, e.g. for implementing HMAC */
39size_t ssh_digest_blocksize(struct ssh_digest_ctx *ctx);
40
41/* Copies internal state of digest of 'from' to 'to' */
42int ssh_digest_copy_state(struct ssh_digest_ctx *from,
43 struct ssh_digest_ctx *to);
44
36/* One-shot API */
37int ssh_digest_memory(int alg, const void *m, size_t mlen,
38 u_char *d, size_t dlen)
39 __attribute__((__bounded__(__buffer__, 2, 3)))
40 __attribute__((__bounded__(__buffer__, 4, 5)));
41int ssh_digest_buffer(int alg, const Buffer *b, u_char *d, size_t dlen)
42 __attribute__((__bounded__(__buffer__, 3, 4)));
43
44/* Update API */
45/* One-shot API */
46int ssh_digest_memory(int alg, const void *m, size_t mlen,
47 u_char *d, size_t dlen)
48 __attribute__((__bounded__(__buffer__, 2, 3)))
49 __attribute__((__bounded__(__buffer__, 4, 5)));
50int ssh_digest_buffer(int alg, const Buffer *b, u_char *d, size_t dlen)
51 __attribute__((__bounded__(__buffer__, 3, 4)));
52
53/* Update API */
45struct ssh_digest_ctx;
46struct ssh_digest_ctx *ssh_digest_start(int alg);
47int ssh_digest_update(struct ssh_digest_ctx *ctx, const void *m, size_t mlen)
48 __attribute__((__bounded__(__buffer__, 2, 3)));
49int ssh_digest_update_buffer(struct ssh_digest_ctx *ctx, const Buffer *b);
50int ssh_digest_final(struct ssh_digest_ctx *ctx, u_char *d, size_t dlen)
51 __attribute__((__bounded__(__buffer__, 2, 3)));
52void ssh_digest_free(struct ssh_digest_ctx *ctx);
53
54#endif /* _DIGEST_H */
55
54struct ssh_digest_ctx *ssh_digest_start(int alg);
55int ssh_digest_update(struct ssh_digest_ctx *ctx, const void *m, size_t mlen)
56 __attribute__((__bounded__(__buffer__, 2, 3)));
57int ssh_digest_update_buffer(struct ssh_digest_ctx *ctx, const Buffer *b);
58int ssh_digest_final(struct ssh_digest_ctx *ctx, u_char *d, size_t dlen)
59 __attribute__((__bounded__(__buffer__, 2, 3)));
60void ssh_digest_free(struct ssh_digest_ctx *ctx);
61
62#endif /* _DIGEST_H */
63