Path: blob/main/crypto/openssl/providers/implementations/skeymgmt/aes_skmgmt.c
48292 views
/*1* Copyright 2025 The OpenSSL Project Authors. All Rights Reserved.2*3* Licensed under the Apache License 2.0 (the "License"). You may not use4* this file except in compliance with the License. You can obtain a copy5* in the file LICENSE in the source distribution or at6* https://www.openssl.org/source/license.html7*/89#include <openssl/core_dispatch.h>10#include "crypto/types.h"11#include "skeymgmt_lcl.h"12#include "internal/skey.h"13#include "prov/implementations.h"1415static OSSL_FUNC_skeymgmt_import_fn aes_import;16static OSSL_FUNC_skeymgmt_export_fn aes_export;1718static void *aes_import(void *provctx, int selection,19const OSSL_PARAM params[])20{21PROV_SKEY *aes = generic_import(provctx, selection, params);2223if (aes == NULL)24return NULL;2526if (aes->length != 16 && aes->length != 24 && aes->length != 32) {27generic_free(aes);28return NULL;29}30aes->type = SKEY_TYPE_AES;3132return aes;33}3435static int aes_export(void *keydata, int selection,36OSSL_CALLBACK *param_callback, void *cbarg)37{38PROV_SKEY *aes = keydata;3940if (aes->type != SKEY_TYPE_AES)41return 0;4243return generic_export(keydata, selection, param_callback, cbarg);44}4546const OSSL_DISPATCH ossl_aes_skeymgmt_functions[] = {47{ OSSL_FUNC_SKEYMGMT_FREE, (void (*)(void))generic_free },48{ OSSL_FUNC_SKEYMGMT_IMPORT, (void (*)(void))aes_import },49{ OSSL_FUNC_SKEYMGMT_EXPORT, (void (*)(void))aes_export },50OSSL_DISPATCH_END51};525354