2 * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
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
10 #include <openssl/md2.h>
11 #include <openssl/crypto.h>
12 #include <openssl/core_numbers.h>
14 static int md2_final(void *ctx, unsigned char *md, size_t *size)
16 if (MD2_Final(md, ctx)) {
17 *size = MD2_DIGEST_LENGTH;
24 static void *md2_newctx(void)
26 MD2_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
31 static void md2_freectx(void *vctx)
33 MD2_CTX *ctx = (MD2_CTX *)vctx;
35 OPENSSL_clear_free(ctx, sizeof(*ctx));
38 static void *md2_dupctx(void *ctx)
40 MD2_CTX *in = (MD2_CTX *)ctx;
41 MD2_CTX *ret = OPENSSL_malloc(sizeof(*ret));
48 static size_t md2_size(void)
50 return MD2_DIGEST_LENGTH;
53 extern const OSSL_DISPATCH md2_functions[];
54 const OSSL_DISPATCH md2_functions[] = {
55 { OSSL_FUNC_DIGEST_NEWCTX, (void (*)(void))md2_newctx },
56 { OSSL_FUNC_DIGEST_INIT, (void (*)(void))MD2_Init },
57 { OSSL_FUNC_DIGEST_UPDDATE, (void (*)(void))MD2_Update },
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 },