Coverage Report

Created: 2025-06-13 06:56

/src/openssl/providers/implementations/skeymgmt/aes_skmgmt.c
Line
Count
Source (jump to first uncovered line)
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
0
{
22
0
    PROV_SKEY *aes = generic_import(provctx, selection, params);
23
24
0
    if (aes == NULL)
25
0
        return NULL;
26
27
0
    if (aes->length != 16 && aes->length != 24 && aes->length != 32) {
28
0
        generic_free(aes);
29
0
        return NULL;
30
0
    }
31
0
    aes->type = SKEY_TYPE_AES;
32
33
0
    return aes;
34
0
}
35
36
static int aes_export(void *keydata, int selection,
37
                      OSSL_CALLBACK *param_callback, void *cbarg)
38
0
{
39
0
    PROV_SKEY *aes = keydata;
40
41
0
    if (aes->type != SKEY_TYPE_AES)
42
0
        return 0;
43
44
0
    return generic_export(keydata, selection, param_callback, cbarg);
45
0
}
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_FUNC_SKEYMGMT_IMP_SETTABLE_PARAMS,
52
      (void (*)(void))generic_imp_settable_params },
53
    OSSL_DISPATCH_END
54
};