1 /* 2 * Copyright 2014-2022 The GmSSL Project. All Rights Reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the License); you may 5 * not use this file except in compliance with the License. 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 */ 9 10 11 #ifndef SDFUTIL_SDF_EXT_H 12 #define SDFUTIL_SDF_EXT_H 13 14 15 #include <stdio.h> 16 #include <stdint.h> 17 #include "../sgd.h" 18 #include "sdf.h" 19 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 26 #define SDF_MIN_KEY_INDEX 1 /* defined by GM/T 0018 */ 27 #define SDF_MAX_KEY_INDEX 32 /* defined by GmSSL */ 28 #define SDF_MIN_PASSWORD_LENGTH 8 /* defined by GM/T 0018 */ 29 #define SDF_MAX_PASSWORD_LENGTH 255 /* defined by GmSSL */ 30 #define SDF_MAX_FILE_SIZE (256 * 1024) 31 32 33 34 int SDF_LoadLibrary(char *so_path, char *vendor); 35 int SDF_UnloadLibrary(void); 36 int SDF_ImportKey(void *hSessionHandle, unsigned char *pucKey, 37 unsigned int uiKeyLength, void **phKeyHandle); 38 39 int SDF_PrintDeviceInfo(FILE *fp, const DEVICEINFO *devInfo); 40 int SDF_PrintRSAPublicKey(FILE *fp, const RSArefPublicKey *ref); 41 int SDF_PrintRSAPrivateKey(FILE *fp, const RSArefPrivateKey *ref); 42 int SDF_PrintECCPublicKey(FILE *fp, const ECCrefPublicKey *ref); 43 int SDF_PrintECCPrivateKey(FILE *fp, const ECCrefPrivateKey *ref); 44 int SDF_NewECCCipher(ECCCipher **cipher, size_t ulDataLen); // FIMXE: 和GmSSL的内存使用方式不同 45 int SDF_FreeECCCipher(ECCCipher *cipher); 46 int SDF_PrintECCCipher(FILE *out, ECCCipher *cipher); 47 int SDF_PrintECCSignature(FILE *out, ECCSignature *sig); 48 const char *SDF_GetErrorReason(int err); 49 50 51 #ifdef __cplusplus 52 } 53 #endif 54 #endif 55