Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/crypto/openssl/providers/implementations/skeymgmt/aes_skmgmt.c
48292 views
1
/*
2
* Copyright 2025 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/core_dispatch.h>
11
#include "crypto/types.h"
12
#include "skeymgmt_lcl.h"
13
#include "internal/skey.h"
14
#include "prov/implementations.h"
15
16
static OSSL_FUNC_skeymgmt_import_fn aes_import;
17
static OSSL_FUNC_skeymgmt_export_fn aes_export;
18
19
static void *aes_import(void *provctx, int selection,
20
const OSSL_PARAM params[])
21
{
22
PROV_SKEY *aes = generic_import(provctx, selection, params);
23
24
if (aes == NULL)
25
return NULL;
26
27
if (aes->length != 16 && aes->length != 24 && aes->length != 32) {
28
generic_free(aes);
29
return NULL;
30
}
31
aes->type = SKEY_TYPE_AES;
32
33
return aes;
34
}
35
36
static int aes_export(void *keydata, int selection,
37
OSSL_CALLBACK *param_callback, void *cbarg)
38
{
39
PROV_SKEY *aes = keydata;
40
41
if (aes->type != SKEY_TYPE_AES)
42
return 0;
43
44
return generic_export(keydata, selection, param_callback, cbarg);
45
}
46
47
const OSSL_DISPATCH ossl_aes_skeymgmt_functions[] = {
48
{ OSSL_FUNC_SKEYMGMT_FREE, (void (*)(void))generic_free },
49
{ OSSL_FUNC_SKEYMGMT_IMPORT, (void (*)(void))aes_import },
50
{ OSSL_FUNC_SKEYMGMT_EXPORT, (void (*)(void))aes_export },
51
OSSL_DISPATCH_END
52
};
53
54