1 /* 2 * Copyright (C) 2022-2024 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_KEY_H 17 #define HCF_KEY_H 18 19 #include "blob.h" 20 #include "result.h" 21 #include "object_base.h" 22 #include "algorithm_parameter.h" 23 24 typedef enum { 25 DSA_P_BN = 101, 26 DSA_Q_BN = 102, 27 DSA_G_BN = 103, 28 DSA_SK_BN = 104, 29 DSA_PK_BN = 105, 30 31 ECC_FP_P_BN = 201, 32 ECC_A_BN = 202, 33 ECC_B_BN = 203, 34 ECC_G_X_BN = 204, 35 ECC_G_Y_BN = 205, 36 ECC_N_BN = 206, 37 ECC_H_INT = 207, // warning: ECC_H_NUM in JS 38 ECC_SK_BN = 208, 39 ECC_PK_X_BN = 209, 40 ECC_PK_Y_BN = 210, 41 ECC_FIELD_TYPE_STR = 211, 42 ECC_FIELD_SIZE_INT = 212, // warning: ECC_FIELD_SIZE_NUM in JS 43 ECC_CURVE_NAME_STR = 213, 44 45 RSA_N_BN = 301, 46 RSA_SK_BN = 302, 47 RSA_PK_BN = 303, 48 49 DH_P_BN = 401, 50 DH_G_BN = 402, 51 DH_L_NUM = 403, 52 DH_SK_BN = 404, 53 DH_PK_BN = 405, 54 55 ED25519_SK_BN = 501, 56 ED25519_PK_BN = 502, 57 X25519_SK_BN = 601, 58 X25519_PK_BN = 602, 59 } AsyKeySpecItem; 60 61 typedef struct HcfKey HcfKey; 62 63 struct HcfKey { 64 HcfObjectBase base; 65 66 const char *(*getAlgorithm)(HcfKey *self); 67 68 HcfResult (*getEncoded)(HcfKey *self, HcfBlob *returnBlob); 69 70 HcfResult (*getEncodedPem)(HcfKey *self, const char *format, char **returnString); 71 72 const char *(*getFormat)(HcfKey *self); 73 }; 74 75 #endif 76