S2OPC OPCUA Toolkit
sopc_key_manager.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 
30 #ifndef SOPC_KEY_MANAGER_H_
31 #define SOPC_KEY_MANAGER_H_
32 
33 #include <stddef.h>
34 
35 #include "sopc_buffer.h"
36 #include "sopc_crypto_decl.h"
37 #include "sopc_secret_buffer.h"
38 
45 
52 
53 /* ------------------------------------------------------------------------------------------------
54  * AsymmetricKey API
55  * ------------------------------------------------------------------------------------------------
56  */
57 
78  uint32_t lenBuf,
79  bool is_public,
80  SOPC_AsymmetricKey** ppKey);
81 
104  SOPC_AsymmetricKey** ppKey,
105  char* password,
106  uint32_t lenPassword);
107 
126  SOPC_AsymmetricKey** pKey);
127 
138 
160  bool is_public,
161  uint8_t* pDest,
162  uint32_t lenDest,
163  uint32_t* pLenWritten);
164 
175  uint32_t len,
177 
188 
199  bool is_public,
200  SOPC_AsymmetricKey** res);
201 
208 
209 /* ------------------------------------------------------------------------------------------------
210  * Cert API
211  * ------------------------------------------------------------------------------------------------
212  */
213 
234  uint32_t lenDER,
235  SOPC_CertificateList** ppCert);
236 
257 
269 
287  uint8_t** ppDest,
288  uint32_t* pLenAllocated);
289 
312  const SOPC_CertificateList* pCert,
313  uint8_t* pDest,
314  uint32_t lenDest);
315 
334 bool SOPC_KeyManager_Certificate_CheckApplicationUri(const SOPC_CertificateList* pCert, const char* applicationUri);
335 
354  char** ppApplicationUri,
355  size_t* pStringLength);
356 
368 
390  const SOPC_CRLList* pCRL,
391  bool* pbMatch);
392 
410  const SOPC_CertificateList* pCert,
411  bool* pbMatch);
412 
423  uint32_t len,
425 
436 
446  SOPC_CertificateList** res);
447 
457 
464 
465 /* ------------------------------------------------------------------------------------------------
466  * Certificate Revocation List API
467  * ------------------------------------------------------------------------------------------------
468  */
469 
490  uint32_t lenDER,
491  SOPC_CRLList** ppCRL);
492 
513 
521 
522 #endif /* SOPC_KEY_MANAGER_H_ */
SOPC_KeyManager_Certificate_CheckApplicationUri
bool SOPC_KeyManager_Certificate_CheckApplicationUri(const SOPC_CertificateList *pCert, const char *applicationUri)
Verify the application URI embedded in a certificate.
SOPC_KeyManager_SerializedAsymmetricKey_Deserialize
SOPC_ReturnStatus SOPC_KeyManager_SerializedAsymmetricKey_Deserialize(const SOPC_SerializedAsymmetricKey *key, bool is_public, SOPC_AsymmetricKey **res)
Deserializes a serialized key.
SOPC_KeyManager_Certificate_CreateOrAddFromFile
SOPC_ReturnStatus SOPC_KeyManager_Certificate_CreateOrAddFromFile(const char *szPath, SOPC_CertificateList **ppCert)
Creates a new Certificate (signed public key) from a file in the DER or PEM format,...
SOPC_KeyManager_SerializedCertificate_Deserialize
SOPC_ReturnStatus SOPC_KeyManager_SerializedCertificate_Deserialize(const SOPC_SerializedCertificate *cert, SOPC_CertificateList **res)
Deserializes a serialized certificate.
SOPC_CertificateList
The signed public key representation, or a chained list of such keys.
Definition: key_manager_lib.h:63
SOPC_SerializedCertificate
SOPC_Buffer SOPC_SerializedCertificate
A serialized representation of a certificate.
Definition: sopc_key_manager.h:51
SOPC_SerializedAsymmetricKey
SOPC_SecretBuffer SOPC_SerializedAsymmetricKey
A serialized representation of an asymmetric key.
Definition: sopc_key_manager.h:44
SOPC_KeyManager_CertificateList_FindCertInList
SOPC_ReturnStatus SOPC_KeyManager_CertificateList_FindCertInList(const SOPC_CertificateList *pList, const SOPC_CertificateList *pCert, bool *pbMatch)
Finds whether a certificate is in the given certificate list or not.
SOPC_KeyManager_Certificate_GetListLength
SOPC_ReturnStatus SOPC_KeyManager_Certificate_GetListLength(const SOPC_CertificateList *pCert, size_t *pLength)
Return the number of chained certificates in the certificate list pCert.
SOPC_KeyManager_CRL_Free
void SOPC_KeyManager_CRL_Free(SOPC_CRLList *pCRL)
Frees a Certificate created with SOPC_KeyManager_CRL_CreateOrAddFromFile() or SOPC_KeyManager_CRL_Cre...
SOPC_KeyManager_SerializedCertificate_Data
const SOPC_Buffer * SOPC_KeyManager_SerializedCertificate_Data(const SOPC_SerializedCertificate *cert)
Returns the data held in a serialized certificate.
SOPC_KeyManager_Certificate_CreateOrAddFromDER
SOPC_ReturnStatus SOPC_KeyManager_Certificate_CreateOrAddFromDER(const uint8_t *bufferDER, uint32_t lenDER, SOPC_CertificateList **ppCert)
Creates a new Certificate (signed public key) from a DER encoded buffer, or add it to an existing cer...
sopc_crypto_decl.h
Defines the common declarations for the cryptographic objects.
SOPC_KeyManager_SerializedAsymmetricKey_CreateFromFile
SOPC_ReturnStatus SOPC_KeyManager_SerializedAsymmetricKey_CreateFromFile(const char *path, SOPC_SerializedAsymmetricKey **key)
Creates a serialized asymmetric key from a file in DER or PEM format.
SOPC_KeyManager_Certificate_GetMaybeApplicationUri
SOPC_ReturnStatus SOPC_KeyManager_Certificate_GetMaybeApplicationUri(const SOPC_CertificateList *pCert, char **ppApplicationUri, size_t *pStringLength)
Copy the application URI embedded in a certificate.
SOPC_KeyManager_AsymmetricKey_CreateFromBuffer
SOPC_ReturnStatus SOPC_KeyManager_AsymmetricKey_CreateFromBuffer(const uint8_t *buffer, uint32_t lenBuf, bool is_public, SOPC_AsymmetricKey **ppKey)
Creates an asymmetric key (usually a private key) from in-memory buffer buffer.
SOPC_KeyManager_AsymmetricKey_ToDER
SOPC_ReturnStatus SOPC_KeyManager_AsymmetricKey_ToDER(const SOPC_AsymmetricKey *pKey, bool is_public, uint8_t *pDest, uint32_t lenDest, uint32_t *pLenWritten)
Encodes the pKey as a DER buffer, and writes the result in pDest.
SOPC_Buffer
Bytes buffer structure.
Definition: sopc_buffer.h:38
SOPC_CryptoProvider
The SOPC_CryptoProvider context.
Definition: sopc_crypto_provider.h:46
SOPC_KeyManager_Certificate_ToDER
SOPC_ReturnStatus SOPC_KeyManager_Certificate_ToDER(const SOPC_CertificateList *pCert, uint8_t **ppDest, uint32_t *pLenAllocated)
Encodes a pCert as a DER buffer and writes the result in ppDest.
SOPC_KeyManager_AsymmetricKey_Free
void SOPC_KeyManager_AsymmetricKey_Free(SOPC_AsymmetricKey *pKey)
Frees a previously created asymmetric key created with SOPC_KeyManager_AsymmetricKey_CreateFromBuffer...
SOPC_KeyManager_SerializedAsymmetricKey_Delete
void SOPC_KeyManager_SerializedAsymmetricKey_Delete(SOPC_SerializedAsymmetricKey *key)
Releases all resources associated to a serialized asymmetric key.
SOPC_KeyManager_CRL_CreateOrAddFromDER
SOPC_ReturnStatus SOPC_KeyManager_CRL_CreateOrAddFromDER(const uint8_t *bufferDER, uint32_t lenDER, SOPC_CRLList **ppCRL)
Creates a new Certificate Revocation List (CRL) from a DER encoded buffer, or add it to an existing C...
SOPC_KeyManager_SerializedCertificate_Delete
void SOPC_KeyManager_SerializedCertificate_Delete(SOPC_SerializedCertificate *cert)
Releases all resources associated to a serialized certificate.
SOPC_KeyManager_SerializedCertificate_CreateFromFile
SOPC_ReturnStatus SOPC_KeyManager_SerializedCertificate_CreateFromFile(const char *path, SOPC_SerializedCertificate **cert)
Creates a serialized certificate from a file in DER format.
SOPC_AsymmetricKey
The asymmetric key representation.
Definition: key_manager_lib.h:43
SOPC_SecretBuffer
struct SOPC_SecretBuffer SOPC_SecretBuffer
Definition: sopc_secret_buffer.h:35
SOPC_KeyManager_SerializedAsymmetricKey_CreateFromData
SOPC_ReturnStatus SOPC_KeyManager_SerializedAsymmetricKey_CreateFromData(const uint8_t *data, uint32_t len, SOPC_SerializedAsymmetricKey **key)
Creates a serialized asymmetric key from a DER or PEM payload.
SOPC_KeyManager_AsymmetricKey_CreateFromCertificate
SOPC_ReturnStatus SOPC_KeyManager_AsymmetricKey_CreateFromCertificate(const SOPC_CertificateList *pCert, SOPC_AsymmetricKey **pKey)
Returns the public key of the signed public key.
SOPC_KeyManager_CertificateList_RemoveUnmatchedCRL
SOPC_ReturnStatus SOPC_KeyManager_CertificateList_RemoveUnmatchedCRL(SOPC_CertificateList *pCert, const SOPC_CRLList *pCRL, bool *pbMatch)
Removes (and frees) certificates from pCert that do not have exactly one revocation list in pCRL.
SOPC_KeyManager_Certificate_GetThumbprint
SOPC_ReturnStatus SOPC_KeyManager_Certificate_GetThumbprint(const SOPC_CryptoProvider *pProvider, const SOPC_CertificateList *pCert, uint8_t *pDest, uint32_t lenDest)
Computes and writes the thumbprint of pCert to pDest.
SOPC_KeyManager_SerializedCertificate_CreateFromDER
SOPC_ReturnStatus SOPC_KeyManager_SerializedCertificate_CreateFromDER(const uint8_t *der, uint32_t len, SOPC_SerializedCertificate **cert)
Creates a serialized certificate from a DER payload.
sopc_secret_buffer.h
SecretBuffer (mangled key) and ExposedBuffer (contiguous deciphered buffered) APIs.
SOPC_KeyManager_AsymmetricKey_CreateFromFile
SOPC_ReturnStatus SOPC_KeyManager_AsymmetricKey_CreateFromFile(const char *szPath, SOPC_AsymmetricKey **ppKey, char *password, uint32_t lenPassword)
Creates an asymmetric key (usually a private key) from a file in the DER or PEM format.
SOPC_CRLList
A list of Certificate Revocation Lists.
Definition: key_manager_lib.h:79
sopc_buffer.h
A buffer of bytes with a maximum size, length and position.
SOPC_KeyManager_Certificate_Free
void SOPC_KeyManager_Certificate_Free(SOPC_CertificateList *pCert)
Frees a Certificate created with SOPC_KeyManager_Certificate_CreateOrAddFromFile() or SOPC_KeyManager...
SOPC_KeyManager_CRL_CreateOrAddFromFile
SOPC_ReturnStatus SOPC_KeyManager_CRL_CreateOrAddFromFile(const char *szPath, SOPC_CRLList **ppCRL)
Creates a new Certificate Revocation List (CRL) from a file in the DER or PEM format,...
SOPC_ReturnStatus
SOPC_ReturnStatus
Definition: libs2opc_client.h:61