TrustCore SDK NanoCert API reference  version 7.0
pkcs1.h
Go to the documentation of this file.
1 /*
2  * pkcs1.h
3  *
4  * PKCS#1 Version 2.1 Header
5  *
6  * Copyright 2019-2024 DigiCert, Inc. All Rights Reserved.
7  * Proprietary and Confidential Material.
8  *
9  */
22 /*------------------------------------------------------------------*/
23 
24 #ifndef __PKCS1_HEADER__
25 #define __PKCS1_HEADER__
26 
27 #ifdef __ENABLE_MOCANA_CRYPTO_INTERFACE_PKCS1__
28 #include "../crypto_interface/crypto_interface_pkcs1_priv.h"
29 #endif
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 
36 /*------------------------------------------------------------------*/
37 
38 /* exported routines */
39 
40 #ifndef MOC_PKCS1_ALG_MGF1
41 #define MOC_PKCS1_ALG_MGF1 1
42 #endif
43 
44 /* For non OpenSSL builds macro the old API into the new API for backwards
45  * compatability. OpenSSL builds cannot define this macro as there are namespace
46  * issues with the old APIs. */
47 #ifndef OPENSSL_ENGINE
48 #ifndef PKCS1_MGF1
49 #define PKCS1_MGF1 PKCS1_MGF1_FUNC
50 #endif /* PKCS1_MGF1 */
51 #endif /* OPENSSL_ENGINE */
52 
57 typedef MSTATUS (*mgfFunc)(MOC_RSA(hwAccelDescr hwAccelCtx) const ubyte *mgfSeed, ubyte4 mgfSeedLen, ubyte4 maskLen, BulkHashAlgo *H, ubyte **ppRetMask);
58 
59 
60 /*------------------------------------------------------------------*/
61 
62 MOC_EXTERN MSTATUS PKCS1_rsaesOaepEncrypt(MOC_RSA(hwAccelDescr hwAccelCtx) randomContext *pRandomContext, const RSAKey *pRSAKey, ubyte H_rsaAlgoId, mgfFunc MGF, const ubyte *M, ubyte4 mLen, const ubyte *L, ubyte4 lLen, ubyte **ppRetEncrypt, ubyte4 *pRetEncryptLen);
63 #if (!defined(__DISABLE_MOCANA_RSA_DECRYPTION__))
64 MOC_EXTERN MSTATUS PKCS1_rsaesOaepDecrypt(MOC_RSA(hwAccelDescr hwAccelCtx) const RSAKey *pRSAKey, ubyte H_rsaAlgoId, mgfFunc MGF, const ubyte *C, ubyte4 cLen, const ubyte *L, ubyte4 lLen, ubyte **ppRetDecrypt, ubyte4 *pRetDecryptLength);
65 #endif
66 
67 #if (!defined(__DISABLE_MOCANA_RSA_DECRYPTION__))
68 MOC_EXTERN MSTATUS PKCS1_rsassaPssSign(MOC_RSA(hwAccelDescr hwAccelCtx) randomContext *pRandomContext, const RSAKey *pRSAKey, ubyte H_rsaAlgoId, mgfFunc MGF, const ubyte *pMessage, ubyte4 mesgLen, ubyte4 saltLen, ubyte **ppRetSignature, ubyte4 *pRetSignatureLen);
69 MOC_EXTERN MSTATUS PKCS1_rsassaFreePssSign(MOC_RSA(hwAccelDescr hwAccelCtx) ubyte **ppSignature);
70 #endif
71 MOC_EXTERN MSTATUS PKCS1_rsassaPssVerify(MOC_RSA(hwAccelDescr hwAccelCtx) const RSAKey *pRSAKey, ubyte H_rsaAlgoId, mgfFunc MGF, const ubyte * const pMessage, ubyte4 mesgLen, const ubyte *pSignature, ubyte4 signatureLen, sbyte4 saltLen, intBoolean *pRetIsSignatureValid);
72 
73 /* helper function */
74 MOC_EXTERN MSTATUS PKCS1_MGF1_FUNC(MOC_RSA(hwAccelDescr hwAccelCtx) const ubyte *mgfSeed, ubyte4 mgfSeedLen, ubyte4 maskLen, BulkHashAlgo *H, ubyte **ppRetMask);
75 
101 MOC_EXTERN MSTATUS PKCS1_rsaOaepEncrypt(
102  MOC_RSA(hwAccelDescr hwAccelCtx)
103  randomContext *pRandomContext,
104  const RSAKey *pRSAKey,
105  ubyte hashAlgo,
106  ubyte mgfAlgo,
107  ubyte mgfHashAlgo,
108  const ubyte *pMessage,
109  ubyte4 mLen,
110  const ubyte *pLabel,
111  ubyte4 lLen,
112  ubyte **ppCipherText,
113  ubyte4 *pCipherTextLen
114  );
115 
138 MOC_EXTERN MSTATUS PKCS1_rsaOaepDecrypt(
139  MOC_RSA(hwAccelDescr hwAccelCtx)
140  const RSAKey *pRSAKey,
141  ubyte hashAlgo,
142  ubyte mgfAlgo,
143  ubyte mgfHashAlgo,
144  const ubyte *pCipherText,
145  ubyte4 cLen,
146  const ubyte *pLabel,
147  ubyte4 lLen,
148  ubyte **ppPlainText,
149  ubyte4 *pPlainTextLen
150  );
151 
176 MOC_EXTERN MSTATUS PKCS1_rsaPssSignExt (
177  MOC_RSA(hwAccelDescr hwAccelCtx)
178  randomContext *pRandomContext,
179  const RSAKey *pRSAKey,
180  ubyte hashAlgo,
181  ubyte mgfAlgo,
182  ubyte mgfHashAlgo,
183  const ubyte *pMessage,
184  ubyte4 mLen,
185  ubyte4 saltLen,
186  ubyte **ppSignature,
187  ubyte4 *pSignatureLen,
188  void *pExtCtx
189  );
190 
214 MOC_EXTERN MSTATUS PKCS1_rsaPssSign (
215  MOC_RSA(hwAccelDescr hwAccelCtx)
216  randomContext *pRandomContext,
217  const RSAKey *pRSAKey,
218  ubyte hashAlgo,
219  ubyte mgfAlgo,
220  ubyte mgfHashAlgo,
221  const ubyte *pMessage,
222  ubyte4 mLen,
223  ubyte4 saltLen,
224  ubyte **ppSignature,
225  ubyte4 *pSignatureLen
226  );
227 
251 MOC_EXTERN MSTATUS PKCS1_rsaPssVerifyExt (
252  MOC_RSA(hwAccelDescr hwAccelCtx)
253  const RSAKey *pRSAKey,
254  ubyte hashAlgo,
255  ubyte mgfAlgo,
256  ubyte mgfHashAlgo,
257  const ubyte *pMessage,
258  ubyte4 mLen,
259  const ubyte *pSignature,
260  ubyte4 signatureLen,
261  sbyte4 saltLen,
262  ubyte4 *pVerify,
263  void *pExtCtx
264  );
265 
288 MOC_EXTERN MSTATUS PKCS1_rsaPssVerify (
289  MOC_RSA(hwAccelDescr hwAccelCtx)
290  const RSAKey *pRSAKey,
291  ubyte hashAlgo,
292  ubyte mgfAlgo,
293  ubyte mgfHashAlgo,
294  const ubyte *pMessage,
295  ubyte4 mLen,
296  const ubyte *pSignature,
297  ubyte4 signatureLen,
298  sbyte4 saltLen,
299  ubyte4 *pVerify
300  );
301 
302 #ifdef __cplusplus
303 }
304 #endif
305 
306 
307 #endif /* __PKCS1_HEADER__ */
MOC_EXTERN MSTATUS PKCS1_rsaPssSign(randomContext *pRandomContext, const RSAKey *pRSAKey, ubyte hashAlgo, ubyte mgfAlgo, ubyte mgfHashAlgo, const ubyte *pMessage, ubyte4 mLen, ubyte4 saltLen, ubyte **ppSignature, ubyte4 *pSignatureLen)
Use the provided RSA Key to sign some data using the PSS scheme.
MOC_EXTERN MSTATUS PKCS1_rsaOaepDecrypt(const RSAKey *pRSAKey, ubyte hashAlgo, ubyte mgfAlgo, ubyte mgfHashAlgo, const ubyte *pCipherText, ubyte4 cLen, const ubyte *pLabel, ubyte4 lLen, ubyte **ppPlainText, ubyte4 *pPlainTextLen)
Perform RSA-OAEP decryption.
MOC_EXTERN MSTATUS PKCS1_rsaPssSignExt(randomContext *pRandomContext, const RSAKey *pRSAKey, ubyte hashAlgo, ubyte mgfAlgo, ubyte mgfHashAlgo, const ubyte *pMessage, ubyte4 mLen, ubyte4 saltLen, ubyte **ppSignature, ubyte4 *pSignatureLen, void *pExtCtx)
Use the provided RSA Key to sign some data using the PSS scheme.
Structure to hold function pointers to hashing or extenable output methods.
Definition: crypto.h:133
MOC_EXTERN MSTATUS PKCS1_rsaOaepEncrypt(randomContext *pRandomContext, const RSAKey *pRSAKey, ubyte hashAlgo, ubyte mgfAlgo, ubyte mgfHashAlgo, const ubyte *pMessage, ubyte4 mLen, const ubyte *pLabel, ubyte4 lLen, ubyte **ppCipherText, ubyte4 *pCipherTextLen)
Perform RSA-OAEP encryption.
MOC_EXTERN MSTATUS PKCS1_rsaPssVerifyExt(const RSAKey *pRSAKey, ubyte hashAlgo, ubyte mgfAlgo, ubyte mgfHashAlgo, const ubyte *pMessage, ubyte4 mLen, const ubyte *pSignature, ubyte4 signatureLen, sbyte4 saltLen, ubyte4 *pVerify, void *pExtCtx)
Use the provided RSA Key to verify a PSS signature.
MOC_EXTERN MSTATUS PKCS1_rsaPssVerify(const RSAKey *pRSAKey, ubyte hashAlgo, ubyte mgfAlgo, ubyte mgfHashAlgo, const ubyte *pMessage, ubyte4 mLen, const ubyte *pSignature, ubyte4 signatureLen, sbyte4 saltLen, ubyte4 *pVerify)
Use the provided RSA Key to verify a PSS signature.
MSTATUS(* mgfFunc)(MOC_RSA(hwAccelDescr hwAccelCtx) const ubyte *mgfSeed, ubyte4 mgfSeedLen, ubyte4 maskLen, BulkHashAlgo *H, ubyte **ppRetMask)
Definition: pkcs1.h:57