VirtualBox

source: vbox/trunk/src/libs/openssl-3.1.7/providers/implementations/ciphers/cipher_sm4_ccm.c@ 106625

最後變更 在這個檔案從106625是 104204,由 vboxsync 提交於 12 月 前

fixing export flags in libs

檔案大小: 1.4 KB
 
1/*
2 * Copyright 2021-2024 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/* Dispatch functions for SM4 CCM mode */
11
12#include "cipher_sm4_ccm.h"
13#include "prov/implementations.h"
14#include "prov/providercommon.h"
15
16static OSSL_FUNC_cipher_freectx_fn sm4_ccm_freectx;
17
18static void *sm4_ccm_newctx(void *provctx, size_t keybits)
19{
20 PROV_SM4_CCM_CTX *ctx;
21
22 if (!ossl_prov_is_running())
23 return NULL;
24
25 ctx = OPENSSL_zalloc(sizeof(*ctx));
26 if (ctx != NULL)
27 ossl_ccm_initctx(&ctx->base, keybits, ossl_prov_sm4_hw_ccm(keybits));
28 return ctx;
29}
30
31static void *sm4_ccm_dupctx(void *provctx)
32{
33 PROV_SM4_CCM_CTX *ctx = provctx;
34 PROV_SM4_CCM_CTX *dctx = NULL;
35
36 if (ctx == NULL)
37 return NULL;
38
39 dctx = OPENSSL_memdup(ctx, sizeof(*ctx));
40 if (dctx != NULL && dctx->base.ccm_ctx.key != NULL)
41 dctx->base.ccm_ctx.key = &dctx->ks.ks;
42
43 return dctx;
44}
45
46static void sm4_ccm_freectx(void *vctx)
47{
48 PROV_SM4_CCM_CTX *ctx = (PROV_SM4_CCM_CTX *)vctx;
49
50 OPENSSL_clear_free(ctx, sizeof(*ctx));
51}
52
53/* sm4128ccm functions */
54IMPLEMENT_aead_cipher(sm4, ccm, CCM, AEAD_FLAGS, 128, 8, 96);
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette