1 /* 2 * Copyright (c) 2021-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 HKS_API_H 17 #define HKS_API_H 18 19 #include "hks_type.h" 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 HKS_API_EXPORT int32_t HksGetSdkVersion(struct HksBlob *sdkVersion); 26 27 HKS_API_EXPORT int32_t HksInitialize(void); 28 29 HKS_API_EXPORT int32_t HksRefreshKeyInfo(void); 30 31 HKS_API_EXPORT int32_t HksGenerateKey(const struct HksBlob *keyAlias, 32 const struct HksParamSet *paramSetIn, struct HksParamSet *paramSetOut); 33 34 HKS_API_EXPORT int32_t HksImportKey(const struct HksBlob *keyAlias, 35 const struct HksParamSet *paramSet, const struct HksBlob *key); 36 37 HKS_API_EXPORT int32_t HksExportPublicKey(const struct HksBlob *keyAlias, 38 const struct HksParamSet *paramSet, struct HksBlob *key); 39 40 HKS_API_EXPORT int32_t HksDeleteKey(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet); 41 42 HKS_API_EXPORT int32_t HksGetKeyParamSet(const struct HksBlob *keyAlias, 43 const struct HksParamSet *paramSetIn, struct HksParamSet *paramSetOut); 44 45 HKS_API_EXPORT int32_t HksKeyExist(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet); 46 47 HKS_API_EXPORT int32_t HksGenerateRandom(const struct HksParamSet *paramSet, struct HksBlob *random); 48 49 HKS_API_EXPORT int32_t HksSign(const struct HksBlob *key, const struct HksParamSet *paramSet, 50 const struct HksBlob *srcData, struct HksBlob *signature); 51 52 HKS_API_EXPORT int32_t HksVerify(const struct HksBlob *key, const struct HksParamSet *paramSet, 53 const struct HksBlob *srcData, const struct HksBlob *signature); 54 55 HKS_API_EXPORT int32_t HksEncrypt(const struct HksBlob *key, const struct HksParamSet *paramSet, 56 const struct HksBlob *plainText, struct HksBlob *cipherText); 57 58 HKS_API_EXPORT int32_t HksDecrypt(const struct HksBlob *key, const struct HksParamSet *paramSet, 59 const struct HksBlob *cipherText, struct HksBlob *plainText); 60 61 HKS_API_EXPORT int32_t HksAgreeKey(const struct HksParamSet *paramSet, const struct HksBlob *privateKey, 62 const struct HksBlob *peerPublicKey, struct HksBlob *agreedKey); 63 64 HKS_API_EXPORT int32_t HksDeriveKey(const struct HksParamSet *paramSet, const struct HksBlob *mainKey, 65 struct HksBlob *derivedKey); 66 67 HKS_API_EXPORT int32_t HksMac(const struct HksBlob *key, const struct HksParamSet *paramSet, 68 const struct HksBlob *srcData, struct HksBlob *mac); 69 70 HKS_API_EXPORT int32_t HksHash(const struct HksParamSet *paramSet, 71 const struct HksBlob *srcData, struct HksBlob *hash); 72 73 HKS_API_EXPORT int32_t HksGetKeyInfoList(const struct HksParamSet *paramSet, 74 struct HksKeyInfo *keyInfoList, uint32_t *listCount); 75 76 HKS_API_EXPORT int32_t HksAttestKey(const struct HksBlob *keyAlias, 77 const struct HksParamSet *paramSet, struct HksCertChain *certChain); 78 79 HKS_API_EXPORT int32_t HksGetCertificateChain(const struct HksBlob *keyAlias, 80 const struct HksParamSet *paramSet, struct HksCertChain *certChain); 81 82 HKS_API_EXPORT int32_t HksWrapKey(const struct HksBlob *keyAlias, const struct HksBlob *targetKeyAlias, 83 const struct HksParamSet *paramSet, struct HksBlob *wrappedData); 84 85 HKS_API_EXPORT int32_t HksUnwrapKey(const struct HksBlob *keyAlias, const struct HksBlob *targetKeyAlias, 86 const struct HksBlob *wrappedData, const struct HksParamSet *paramSet); 87 88 HKS_API_EXPORT int32_t HksBnExpMod(struct HksBlob *x, const struct HksBlob *a, 89 const struct HksBlob *e, const struct HksBlob *n); 90 91 HKS_API_EXPORT int32_t HksInit(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet, 92 struct HksBlob *handle); 93 94 HKS_API_EXPORT int32_t HksUpdate(const struct HksBlob *handle, const struct HksParamSet *paramSet, 95 const struct HksBlob *inData, struct HksBlob *outData); 96 97 HKS_API_EXPORT int32_t HksFinish(const struct HksBlob *handle, const struct HksParamSet *paramSet, 98 const struct HksBlob *inData, struct HksBlob *outData); 99 100 HKS_API_EXPORT int32_t HksAbort(const struct HksBlob *handle, const struct HksParamSet *paramSet); 101 102 #ifdef __cplusplus 103 } 104 #endif 105 106 #endif /* HKS_API_H */ 107