Debian Codegraph @

debian/rust-vendor/aws-lc-sys/aws-lc/crypto/fipsmodule/digest/internal.h

raw
1 // Copyright (C) 1995-1998 Eric Young ([email protected]) All rights reserved.
2 // SPDX-License-Identifier: Apache-2.0
3
4 #ifndef OPENSSL_HEADER_DIGEST_INTERNAL_H
5 #define OPENSSL_HEADER_DIGEST_INTERNAL_H
6
7 #include <openssl/base.h>
8
9 #if defined(__cplusplus)
10 extern "C" {
11 #endif
12
13
14 // env_md_st is typoed ("evp" -> "env"), but the typo comes from OpenSSL and
15 // some consumers forward-declare these structures so we're leaving it alone.
16 struct env_md_st {
17 // type contains a NID identifing the digest function. (For example,
18 // NID_md5.)
19 int type;
20
21 // md_size contains the size, in bytes, of the resulting digest.
22 unsigned md_size;
23
24 // flags contains the OR of |EVP_MD_FLAG_*| values.
25 uint32_t flags;
26
27 // init initialises the state in |ctx->md_data|.
28 void (*init)(EVP_MD_CTX *ctx);
29
30 // update hashes |len| bytes of |data| into the state in |ctx->md_data|.
31 // Digest update functions propagate the internal functions return value.
32 // update calls after |final| are restricted via |ctx| check (|final|
33 // cleanses the |ctx|). Digest XOF update returns 1 on success and 0 on
34 // failure. Failures can only occur on a digest XOF update if called after
35 // |squeezeXOF| or |finalXOF|.
36 int (*update)(EVP_MD_CTX *ctx, const void *data, size_t count);
37
38 // final completes the hash and writes |md_size| bytes of digest to |out|.
39 void (*final)(EVP_MD_CTX *ctx, uint8_t *out);
40
41 // block_size contains the hash's native block size.
42 unsigned block_size;
43
44 // ctx_size contains the size, in bytes, of the state of the hash function.
45 unsigned ctx_size;
46
47 // finalXOF completes the hash and writes |len| bytes of digest extended
48 // output to |out|. Digest XOF finalXOF function propagates the return
49 // value from |SHAKE_Final|, that is 1 on success and 0 on failure,
50 // to restrict single-call finalXOF calls after |squeezeXOF|.
51 int (*finalXOF)(EVP_MD_CTX *ctx, uint8_t *out, size_t len);
52
53 // squeezeXOF incrementally generates |len| bytes of digest extended output
54 // to |out|.
55 void (*squeezeXOF)(EVP_MD_CTX *ctx, uint8_t *out, size_t len);
56 };
57
58 // evp_md_pctx_ops contains function pointers to allow the |pctx| member of
59 // |EVP_MD_CTX| to be manipulated without breaking layering by calling EVP
60 // functions.
61 struct evp_md_pctx_ops {
62 // free is called when an |EVP_MD_CTX| is being freed and the |pctx| also
63 // needs to be freed.
64 void (*free)(EVP_PKEY_CTX *pctx);
65
66 // dup is called when an |EVP_MD_CTX| is copied and so the |pctx| also needs
67 // to be copied.
68 EVP_PKEY_CTX *(*dup)(EVP_PKEY_CTX *pctx);
69 };
70
71
72 #if defined(__cplusplus)
73 } // extern C
74 #endif
75
76 #endif // OPENSSL_HEADER_DIGEST_INTERNAL