]> git.ipfire.org Git - thirdparty/openssl.git/blame - providers/legacy/digests/md2.c
Make EVP_Encrypt*/EVP_Decrypt* and EVP_Cipher* provider aware
[thirdparty/openssl.git] / providers / legacy / digests / md2.c
CommitLineData
d0308923
MC
1/*
2 * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License 2.0 (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#include <openssl/md2.h>
11#include <openssl/crypto.h>
12#include <openssl/core_numbers.h>
13
14static int md2_final(void *ctx, unsigned char *md, size_t *size)
15{
16 if (MD2_Final(md, ctx)) {
17 *size = MD2_DIGEST_LENGTH;
18 return 1;
19 }
20
21 return 0;
22}
23
24static void *md2_newctx(void)
25{
26 MD2_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
27
28 return ctx;
29}
30
31static void md2_freectx(void *vctx)
32{
33 MD2_CTX *ctx = (MD2_CTX *)vctx;
34
35 OPENSSL_clear_free(ctx, sizeof(*ctx));
36}
37
38static void *md2_dupctx(void *ctx)
39{
40 MD2_CTX *in = (MD2_CTX *)ctx;
41 MD2_CTX *ret = OPENSSL_malloc(sizeof(*ret));
42
43 *ret = *in;
44
45 return ret;
46}
47
48static size_t md2_size(void)
49{
50 return MD2_DIGEST_LENGTH;
51}
52
53extern const OSSL_DISPATCH md2_functions[];
54const OSSL_DISPATCH md2_functions[] = {
55 { OSSL_FUNC_DIGEST_NEWCTX, (void (*)(void))md2_newctx },
56 { OSSL_FUNC_DIGEST_INIT, (void (*)(void))MD2_Init },
df05f2ce 57 { OSSL_FUNC_DIGEST_UPDATE, (void (*)(void))MD2_Update },
d0308923
MC
58 { OSSL_FUNC_DIGEST_FINAL, (void (*)(void))md2_final },
59 { OSSL_FUNC_DIGEST_FREECTX, (void (*)(void))md2_freectx },
60 { OSSL_FUNC_DIGEST_DUPCTX, (void (*)(void))md2_dupctx },
61 { OSSL_FUNC_DIGEST_SIZE, (void (*)(void))md2_size },
62 { 0, NULL }
63};