• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the OpenSSL license (the "License").  You may not use
5  * this file except in compliance with the License.  You can obtain a copy
6  * in the file LICENSE in the source distribution or at
7  * https://www.openssl.org/source/license.html
8  */
9 
10 #ifndef OPENSSL_HEADER_DIGEST_INTERNAL_H
11 #define OPENSSL_HEADER_DIGEST_INTERNAL_H
12 
13 #include <openssl/base.h>
14 
15 #if defined(__cplusplus)
16 extern "C" {
17 #endif
18 
19 
20 struct env_md_st {
21   // type contains a NID identifing the digest function. (For example,
22   // NID_md5.)
23   int type;
24 
25   // md_size contains the size, in bytes, of the resulting digest.
26   unsigned md_size;
27 
28   // flags contains the OR of |EVP_MD_FLAG_*| values.
29   uint32_t flags;
30 
31   // init initialises the state in |ctx->md_data|.
32   void (*init)(EVP_MD_CTX *ctx);
33 
34   // update hashes |len| bytes of |data| into the state in |ctx->md_data|.
35   void (*update)(EVP_MD_CTX *ctx, const void *data, size_t count);
36 
37   // final completes the hash and writes |md_size| bytes of digest to |out|.
38   void (*final)(EVP_MD_CTX *ctx, uint8_t *out);
39 
40   // block_size contains the hash's native block size.
41   unsigned block_size;
42 
43   // ctx_size contains the size, in bytes, of the state of the hash function.
44   unsigned ctx_size;
45 };
46 
47 // evp_md_pctx_ops contains function pointers to allow the |pctx| member of
48 // |EVP_MD_CTX| to be manipulated without breaking layering by calling EVP
49 // functions.
50 struct evp_md_pctx_ops {
51   // free is called when an |EVP_MD_CTX| is being freed and the |pctx| also
52   // needs to be freed.
53   void (*free) (EVP_PKEY_CTX *pctx);
54 
55   // dup is called when an |EVP_MD_CTX| is copied and so the |pctx| also needs
56   // to be copied.
57   EVP_PKEY_CTX* (*dup) (EVP_PKEY_CTX *pctx);
58 };
59 
60 
61 #if defined(__cplusplus)
62 }  // extern C
63 #endif
64 
65 #endif  // OPENSSL_HEADER_DIGEST_INTERNAL
66