1 /* 2 * Copyright (C) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef HCF_ASY_KEY_GENERATOR_H 17 #define HCF_ASY_KEY_GENERATOR_H 18 19 #include <stdint.h> 20 #include "algorithm_parameter.h" 21 #include "result.h" 22 #include "key_pair.h" 23 24 enum HcfRsaKeySize { 25 HCF_RSA_KEY_SIZE_512 = 512, 26 HCF_RSA_KEY_SIZE_768 = 768, 27 HCF_RSA_KEY_SIZE_1024 = 1024, 28 HCF_RSA_KEY_SIZE_2048 = 2048, 29 HCF_RSA_KEY_SIZE_3072 = 3072, 30 HCF_RSA_KEY_SIZE_4096 = 4096, 31 HCF_RSA_KEY_SIZE_8192 = 8192, 32 }; 33 34 enum HcfRsaPrimesSize { 35 HCF_RSA_PRIMES_SIZE_2 = 2, 36 HCF_RSA_PRIMES_SIZE_3 = 3, 37 HCF_RSA_PRIMES_SIZE_4 = 4, 38 HCF_RSA_PRIMES_SIZE_5 = 5, 39 }; 40 41 typedef struct HcfAsyKeyGenerator HcfAsyKeyGenerator; 42 43 struct HcfAsyKeyGenerator { 44 HcfObjectBase base; 45 46 HcfResult (*generateKeyPair)(HcfAsyKeyGenerator *self, HcfParamsSpec *params, 47 HcfKeyPair **returnKeyPair); 48 49 HcfResult (*convertKey)(HcfAsyKeyGenerator *self, HcfParamsSpec *params, HcfBlob *pubKeyBlob, 50 HcfBlob *priKeyBlob, HcfKeyPair **returnKeyPair); 51 52 const char *(*getAlgoName)(HcfAsyKeyGenerator *self); 53 }; 54 55 #ifdef __cplusplus 56 extern "C" { 57 #endif 58 59 HcfResult HcfAsyKeyGeneratorCreate(const char *algoName, HcfAsyKeyGenerator **returnObj); 60 61 #ifdef __cplusplus 62 } 63 #endif 64 65 #endif 66