S2OPC OPCUA Toolkit
crypto_functions_lib.h
Go to the documentation of this file.
1 /*
2  * Licensed to Systerel under one or more contributor license
3  * agreements. See the NOTICE file distributed with this work
4  * for additional information regarding copyright ownership.
5  * Systerel licenses this file to you under the Apache
6  * License, Version 2.0 (the "License"); you may not use this
7  * file except in compliance with the License. You may obtain
8  * a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
25 #ifndef SOPC_CRYPTO_FUNCTIONS_LIB_H_
26 #define SOPC_CRYPTO_FUNCTIONS_LIB_H_
27 
28 #include "sopc_crypto_decl.h"
29 #include "sopc_key_manager.h"
30 #include "sopc_secret_buffer.h"
31 
32 /* ------------------------------------------------------------------------------------------------
33  * Aes128-Sha256-RsaOaep
34  * ------------------------------------------------------------------------------------------------
35  */
36 
38  const uint8_t* pInput,
39  uint32_t lenPlainText,
40  const SOPC_ExposedBuffer* pKey,
41  const SOPC_ExposedBuffer* pIV,
42  uint8_t* pOutput,
43  uint32_t lenOutput);
45  const uint8_t* pInput,
46  uint32_t lenCipherText,
47  const SOPC_ExposedBuffer* pKey,
48  const SOPC_ExposedBuffer* pIV,
49  uint8_t* pOutput,
50  uint32_t lenOutput);
51 
52 /* ------------------------------------------------------------------------------------------------
53  * Basic256Sha256
54  * ------------------------------------------------------------------------------------------------
55  */
56 
58  const uint8_t* pInput,
59  uint32_t lenPlainText,
60  const SOPC_ExposedBuffer* pKey,
61  const SOPC_ExposedBuffer* pIV,
62  uint8_t* pOutput,
63  uint32_t lenOutput);
65  const uint8_t* pInput,
66  uint32_t lenCipherText,
67  const SOPC_ExposedBuffer* pKey,
68  const SOPC_ExposedBuffer* pIV,
69  uint8_t* pOutput,
70  uint32_t lenOutput);
72  const uint8_t* pInput,
73  uint32_t lenInput,
74  const SOPC_ExposedBuffer* pKey,
75  uint8_t* pOutput);
77  const uint8_t* pInput,
78  uint32_t lenInput,
79  const SOPC_ExposedBuffer* pKey,
80  const uint8_t* pSignature);
82  SOPC_ExposedBuffer* pData,
83  uint32_t lenData);
85  const SOPC_ExposedBuffer* pSecret,
86  uint32_t lenSecret,
87  const SOPC_ExposedBuffer* pSeed,
88  uint32_t lenSeed,
89  SOPC_ExposedBuffer* pOutput,
90  uint32_t lenOutput);
91 
93  const uint8_t* pInput,
94  uint32_t lenPlainText,
95  const SOPC_AsymmetricKey* pKey,
96  uint8_t* pOutput);
98  const uint8_t* pInput,
99  uint32_t lenPlainText,
100  const SOPC_AsymmetricKey* pKey,
101  uint8_t* pOutput,
102  uint32_t* pLenWritten);
103 
105  const uint8_t* pInput,
106  uint32_t lenInput,
107  const SOPC_AsymmetricKey* pKey,
108  uint8_t* pSignature);
110  const uint8_t* pInput,
111  uint32_t lenInput,
112  const SOPC_AsymmetricKey* pKey,
113  const uint8_t* pSignature);
114 
116  const SOPC_CertificateList* pCert);
117 
118 /* ------------------------------------------------------------------------------------------------
119  * Aes256-Sha256-RsaOaep
120  * ------------------------------------------------------------------------------------------------
121  */
122 
124  const uint8_t* pInput,
125  uint32_t lenPlainText,
126  const SOPC_AsymmetricKey* pKey,
127  uint8_t* pOutput);
129  const uint8_t* pInput,
130  uint32_t lenPlainText,
131  const SOPC_AsymmetricKey* pKey,
132  uint8_t* pOutput,
133  uint32_t* pLenWritten);
135  const uint8_t* pInput,
136  uint32_t lenInput,
137  const SOPC_AsymmetricKey* pKey,
138  uint8_t* pSignature);
140  const uint8_t* pInput,
141  uint32_t lenInput,
142  const SOPC_AsymmetricKey* pKey,
143  const uint8_t* pSignature);
144 
145 /* ------------------------------------------------------------------------------------------------
146  * Basic256
147  * ------------------------------------------------------------------------------------------------
148  */
149 
151  const uint8_t* pInput,
152  uint32_t lenInput,
153  const SOPC_ExposedBuffer* pKey,
154  uint8_t* pOutput);
156  const uint8_t* pInput,
157  uint32_t lenInput,
158  const SOPC_ExposedBuffer* pKey,
159  const uint8_t* pSignature);
161  const SOPC_ExposedBuffer* pSecret,
162  uint32_t lenSecret,
163  const SOPC_ExposedBuffer* pSeed,
164  uint32_t lenSeed,
165  SOPC_ExposedBuffer* pOutput,
166  uint32_t lenOutput);
168  const uint8_t* pInput,
169  uint32_t lenInput,
170  const SOPC_AsymmetricKey* pKey,
171  uint8_t* pSignature);
173  const uint8_t* pInput,
174  uint32_t lenInput,
175  const SOPC_AsymmetricKey* pKey,
176  const uint8_t* pSignature);
178  const SOPC_CertificateList* pCert);
179 
180 /* ------------------------------------------------------------------------------------------------
181  * PubSub AES-256
182  * ------------------------------------------------------------------------------------------------
183  */
184 
186  const uint8_t* pInput,
187  uint32_t lenInput,
188  const SOPC_ExposedBuffer* pKey,
189  const SOPC_ExposedBuffer* pKeyNonce,
190  const SOPC_ExposedBuffer* pRandom,
191  uint32_t uSequenceNumber,
192  uint8_t* pOutput);
193 #endif /* SOPC_CRYPTO_FUNCTIONS_LIB_H_ */
CryptoProvider_SymmEncrypt_AES128
SOPC_ReturnStatus CryptoProvider_SymmEncrypt_AES128(const SOPC_CryptoProvider *pProvider, const uint8_t *pInput, uint32_t lenPlainText, const SOPC_ExposedBuffer *pKey, const SOPC_ExposedBuffer *pIV, uint8_t *pOutput, uint32_t lenOutput)
CryptoProvider_CertVerify_RSA_SHA1_SHA256_1024_2048
SOPC_ReturnStatus CryptoProvider_CertVerify_RSA_SHA1_SHA256_1024_2048(const SOPC_CryptoProvider *pCrypto, const SOPC_CertificateList *pCert)
SOPC_CertificateList
The signed public key representation, or a chained list of such keys.
Definition: key_manager_lib.h:66
CryptoProvider_SymmEncrypt_AES256
SOPC_ReturnStatus CryptoProvider_SymmEncrypt_AES256(const SOPC_CryptoProvider *pProvider, const uint8_t *pInput, uint32_t lenPlainText, const SOPC_ExposedBuffer *pKey, const SOPC_ExposedBuffer *pIV, uint8_t *pOutput, uint32_t lenOutput)
CryptoProvider_AsymVerify_RSASSA_PKCS1_v15_w_SHA1
SOPC_ReturnStatus CryptoProvider_AsymVerify_RSASSA_PKCS1_v15_w_SHA1(const SOPC_CryptoProvider *pProvider, const uint8_t *pInput, uint32_t lenInput, const SOPC_AsymmetricKey *pKey, const uint8_t *pSignature)
sopc_key_manager.h
The SOPC_KeyManager provides an API for Asymmetric Key Management such as loading signed public keys ...
CryptoProvider_AsymSign_RSASSA_PKCS1_v15_w_SHA256
SOPC_ReturnStatus CryptoProvider_AsymSign_RSASSA_PKCS1_v15_w_SHA256(const SOPC_CryptoProvider *pProvider, const uint8_t *pInput, uint32_t lenInput, const SOPC_AsymmetricKey *pKey, uint8_t *pSignature)
CryptoProvider_AsymVerify_RSASSA_PSS
SOPC_ReturnStatus CryptoProvider_AsymVerify_RSASSA_PSS(const SOPC_CryptoProvider *pProvider, const uint8_t *pInput, uint32_t lenInput, const SOPC_AsymmetricKey *pKey, const uint8_t *pSignature)
CryptoProvider_AsymSign_RSASSA_PKCS1_v15_w_SHA1
SOPC_ReturnStatus CryptoProvider_AsymSign_RSASSA_PKCS1_v15_w_SHA1(const SOPC_CryptoProvider *pProvider, const uint8_t *pInput, uint32_t lenInput, const SOPC_AsymmetricKey *pKey, uint8_t *pSignature)
CryptoProvider_AsymDecrypt_RSA_OAEP_SHA256
SOPC_ReturnStatus CryptoProvider_AsymDecrypt_RSA_OAEP_SHA256(const SOPC_CryptoProvider *pProvider, const uint8_t *pInput, uint32_t lenPlainText, const SOPC_AsymmetricKey *pKey, uint8_t *pOutput, uint32_t *pLenWritten)
CryptoProvider_SymmDecrypt_AES256
SOPC_ReturnStatus CryptoProvider_SymmDecrypt_AES256(const SOPC_CryptoProvider *pProvider, const uint8_t *pInput, uint32_t lenCipherText, const SOPC_ExposedBuffer *pKey, const SOPC_ExposedBuffer *pIV, uint8_t *pOutput, uint32_t lenOutput)
CryptoProvider_SymmSign_HMAC_SHA1
SOPC_ReturnStatus CryptoProvider_SymmSign_HMAC_SHA1(const SOPC_CryptoProvider *pProvider, const uint8_t *pInput, uint32_t lenInput, const SOPC_ExposedBuffer *pKey, uint8_t *pOutput)
sopc_crypto_decl.h
Defines the common declarations for the cryptographic objects.
CryptoProvider_GenTrueRnd
SOPC_ReturnStatus CryptoProvider_GenTrueRnd(const SOPC_CryptoProvider *pProvider, SOPC_ExposedBuffer *pData, uint32_t lenData)
CryptoProvider_AsymDecrypt_RSA_OAEP
SOPC_ReturnStatus CryptoProvider_AsymDecrypt_RSA_OAEP(const SOPC_CryptoProvider *pProvider, const uint8_t *pInput, uint32_t lenPlainText, const SOPC_AsymmetricKey *pKey, uint8_t *pOutput, uint32_t *pLenWritten)
CryptoProvider_DeriveData_PRF_SHA1
SOPC_ReturnStatus CryptoProvider_DeriveData_PRF_SHA1(const SOPC_CryptoProvider *pProvider, const SOPC_ExposedBuffer *pSecret, uint32_t lenSecret, const SOPC_ExposedBuffer *pSeed, uint32_t lenSeed, SOPC_ExposedBuffer *pOutput, uint32_t lenOutput)
SOPC_CryptoProvider
The SOPC_CryptoProvider context.
Definition: sopc_crypto_provider.h:47
CryptoProvider_CertVerify_RSA_SHA256_2048_4096
SOPC_ReturnStatus CryptoProvider_CertVerify_RSA_SHA256_2048_4096(const SOPC_CryptoProvider *pCrypto, const SOPC_CertificateList *pCert)
CryptoProvider_SymmVerify_HMAC_SHA1
SOPC_ReturnStatus CryptoProvider_SymmVerify_HMAC_SHA1(const SOPC_CryptoProvider *pProvider, const uint8_t *pInput, uint32_t lenInput, const SOPC_ExposedBuffer *pKey, const uint8_t *pSignature)
CryptoProvider_AsymEncrypt_RSA_OAEP
SOPC_ReturnStatus CryptoProvider_AsymEncrypt_RSA_OAEP(const SOPC_CryptoProvider *pProvider, const uint8_t *pInput, uint32_t lenPlainText, const SOPC_AsymmetricKey *pKey, uint8_t *pOutput)
CryptoProvider_SymmDecrypt_AES128
SOPC_ReturnStatus CryptoProvider_SymmDecrypt_AES128(const SOPC_CryptoProvider *pProvider, const uint8_t *pInput, uint32_t lenCipherText, const SOPC_ExposedBuffer *pKey, const SOPC_ExposedBuffer *pIV, uint8_t *pOutput, uint32_t lenOutput)
SOPC_AsymmetricKey
The asymmetric key representation.
Definition: key_manager_lib.h:46
CryptoProvider_CTR_Crypt_AES256
SOPC_ReturnStatus CryptoProvider_CTR_Crypt_AES256(const SOPC_CryptoProvider *pProvider, const uint8_t *pInput, uint32_t lenInput, const SOPC_ExposedBuffer *pKey, const SOPC_ExposedBuffer *pKeyNonce, const SOPC_ExposedBuffer *pRandom, uint32_t uSequenceNumber, uint8_t *pOutput)
SOPC_ExposedBuffer
uint8_t SOPC_ExposedBuffer
Definition: sopc_secret_buffer.h:36
CryptoProvider_AsymVerify_RSASSA_PKCS1_v15_w_SHA256
SOPC_ReturnStatus CryptoProvider_AsymVerify_RSASSA_PKCS1_v15_w_SHA256(const SOPC_CryptoProvider *pProvider, const uint8_t *pInput, uint32_t lenInput, const SOPC_AsymmetricKey *pKey, const uint8_t *pSignature)
CryptoProvider_SymmVerify_HMAC_SHA256
SOPC_ReturnStatus CryptoProvider_SymmVerify_HMAC_SHA256(const SOPC_CryptoProvider *pProvider, const uint8_t *pInput, uint32_t lenInput, const SOPC_ExposedBuffer *pKey, const uint8_t *pSignature)
CryptoProvider_AsymEncrypt_RSA_OAEP_SHA256
SOPC_ReturnStatus CryptoProvider_AsymEncrypt_RSA_OAEP_SHA256(const SOPC_CryptoProvider *pProvider, const uint8_t *pInput, uint32_t lenPlainText, const SOPC_AsymmetricKey *pKey, uint8_t *pOutput)
sopc_secret_buffer.h
SecretBuffer (mangled key) and ExposedBuffer (contiguous deciphered buffered) APIs.
CryptoProvider_DeriveData_PRF_SHA256
SOPC_ReturnStatus CryptoProvider_DeriveData_PRF_SHA256(const SOPC_CryptoProvider *pProvider, const SOPC_ExposedBuffer *pSecret, uint32_t lenSecret, const SOPC_ExposedBuffer *pSeed, uint32_t lenSeed, SOPC_ExposedBuffer *pOutput, uint32_t lenOutput)
CryptoProvider_SymmSign_HMAC_SHA256
SOPC_ReturnStatus CryptoProvider_SymmSign_HMAC_SHA256(const SOPC_CryptoProvider *pProvider, const uint8_t *pInput, uint32_t lenInput, const SOPC_ExposedBuffer *pKey, uint8_t *pOutput)
CryptoProvider_AsymSign_RSASSA_PSS
SOPC_ReturnStatus CryptoProvider_AsymSign_RSASSA_PSS(const SOPC_CryptoProvider *pProvider, const uint8_t *pInput, uint32_t lenInput, const SOPC_AsymmetricKey *pKey, uint8_t *pSignature)
SOPC_ReturnStatus
SOPC_ReturnStatus
Definition: libs2opc_client.h:61