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