| 6 | // |
| 7 | // https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 |
| 15 | #ifndef OPENSSL_HEADER_CRYPTO_FIPSMODULE_DIGEST_INTERNAL_H |
| 16 | #define OPENSSL_HEADER_CRYPTO_FIPSMODULE_DIGEST_INTERNAL_H |
| 17 |
| 18 | #include <openssl/base.h> |
| 19 |
| 20 | #if defined(__cplusplus) |
| 21 | extern "C" { |
| 22 | #endif |
| 23 |
| 24 |
| 25 | struct env_md_st { |
| 26 | // type contains a NID identifing the digest function. (For example, |
| 27 | // NID_md5.) |
| 28 | int type; |
| 29 |
| 30 | // md_size contains the size, in bytes, of the resulting digest. |
| 31 | unsigned md_size; |
| 32 |
| 33 | // flags contains the OR of |EVP_MD_FLAG_*| values. |
| 34 | uint32_t flags; |
| 35 |
| 36 | // init initialises the state in |ctx->md_data|. |
| 37 | void (*init)(EVP_MD_CTX *ctx); |
| 38 |
| 39 | // update hashes |len| bytes of |data| into the state in |ctx->md_data|. |
| 40 | void (*update)(EVP_MD_CTX *ctx, const void *data, size_t count); |
| 41 |
| 42 | // final completes the hash and writes |md_size| bytes of digest to |out|. |
| 43 | void (*final)(EVP_MD_CTX *ctx, uint8_t *out); |
| 44 |
| 45 | // block_size contains the hash's native block size. |
| 46 | unsigned block_size; |
| 47 |
| 48 | // ctx_size contains the size, in bytes, of the state of the hash function. |
| 49 | unsigned ctx_size; |
| 50 | }; |
| 51 |
| 52 | // evp_md_pctx_ops contains function pointers to allow the |pctx| member of |
| 53 | // |EVP_MD_CTX| to be manipulated without breaking layering by calling EVP |
| 54 | // functions. |
| 55 | struct evp_md_pctx_ops { |
| 56 | // free is called when an |EVP_MD_CTX| is being freed and the |pctx| also |
| 57 | // needs to be freed. |
| 58 | void (*free) (EVP_PKEY_CTX *pctx); |
| 59 |
| 60 | // dup is called when an |EVP_MD_CTX| is copied and so the |pctx| also needs |
| 61 | // to be copied. |
| 62 | EVP_PKEY_CTX* (*dup) (EVP_PKEY_CTX *pctx); |
| 63 | }; |
| 64 |
| 65 |
| 66 | #if defined(__cplusplus) |
| 67 | } // extern C |
| 68 | #endif |
| 69 |
| 70 | #endif // OPENSSL_HEADER_CRYPTO_FIPSMODULE_DIGEST_INTERNAL_H |
| 71 |