|
Couchbase Lite C
Couchbase Lite C API
|
TLSIdentity represents identity information, including an RSA key pair and certificates, used for server or client authentication as well as data encryption / decryption in TLS communication. More...
Data Structures | |
| struct | CBLExternalKeyCallbacks |
| Callbacks for performing cryptographic operations with an externally managed key pair. More... | |
Typedefs | |
| typedef struct CBLCert | CBLCert |
| An opaque object representing the X.509 Certifcate. | |
TLS Identity | |
| enum | CBLKeyUsages : uint16_t { kCBLKeyUsagesClientAuth = 0x80 , kCBLKeyUsagesServerAuth = 0x40 } |
| typedef struct CBLTLSIdentity | CBLTLSIdentity |
| An opaque object representing the TLSIdentity. | |
| static const CBLTLSIdentity * | CBLTLSIdentity_Retain (const CBLTLSIdentity *_cbl_nullable t) |
| static void | CBLTLSIdentity_Release (const CBLTLSIdentity *_cbl_nullable t) |
| _cbl_warn_unused CBLCert * | CBLTLSIdentity_Certificates (CBLTLSIdentity *identity) |
| Returns the certificate chain associated with the given TLS identity. | |
| CBLTimestamp | CBLTLSIdentity_Expiration (CBLTLSIdentity *identity) |
| Returns the date/time at which the first certificate in the chain expires. | |
| _cbl_warn_unused CBLTLSIdentity *_cbl_nullable | CBLTLSIdentity_CreateIdentity (CBLKeyUsages keyUsages, FLDict attributes, int64_t validityInMilliseconds, FLString label, CBLError *_cbl_nullable outError) |
| Creates a self-signed TLS identity using the specified certificate attributes. | |
| _cbl_warn_unused CBLTLSIdentity *_cbl_nullable | CBLTLSIdentity_CreateIdentityWithKeyPair (CBLKeyUsages keyUsages, CBLKeyPair *keypair, FLDict attributes, int64_t validityInMilliseconds, CBLError *_cbl_nullable outError) |
| Creates a self-signed TLS identity using the provided RSA key pair and certificate attributes. | |
| bool | CBLTLSIdentity_DeleteIdentityWithLabel (FLString label, CBLError *_cbl_nullable outError) |
| Deletes the TLS identity associated with the given persistent label from the platform's keystore (Keychain on Apple platforms or CNG Key Storage Provider on Windows). | |
| _cbl_warn_unused CBLTLSIdentity *_cbl_nullable | CBLTLSIdentity_IdentityWithLabel (FLString label, CBLError *_cbl_nullable outError) |
| Retrieves a TLS identity associated with the given persistent label from the platform's keystore (Keychain on Apple platforms or CNG Key Storage Provider on Windows). | |
| _cbl_warn_unused CBLTLSIdentity *_cbl_nullable | CBLTLSIdentity_IdentityWithKeyPairAndCerts (CBLKeyPair *keypair, CBLCert *cert, CBLError *_cbl_nullable outError) |
| Returns a TLS identity from an existing identity using the provided RSA keypair and certificate chain. | |
| _cbl_warn_unused CBLTLSIdentity *_cbl_nullable | CBLTLSIdentity_IdentityWithCerts (CBLCert *cert, CBLError *_cbl_nullable outError) |
| Returns an existing TLS identity associated with the provided certificate chain in the keystore (Keychain for Apple or CNG Key Storage Provider for Windows). | |
TLSIdentity represents identity information, including an RSA key pair and certificates, used for server or client authentication as well as data encryption / decryption in TLS communication.
Couchbase Lite C provides functions for generating a new self-signed identity or using an existing identity. Similar to other Couchbase Lite platforms, when using Couchbase Lite C, a generated self-signed identity can be persisted using a specified label in the secure key storage, depending on the operating system as follows:
The generated identity will be stored in the platform’s secure key storage as follows:
Due to the limitation that Linux-based operating systems do not have a standard or common secure key storage, and Android doesn’t support native C/C++ API access to the default keystore, Couchbase Lite C does not support persisting generated identities with the specified label on these platforms.
Alternatively, Couchbase Lite C allows developers to implement their own cryptographic operations through a set of callbacks, enabling certificate signing and data encryption / decryption using a private key stored in their preferred secure key storage. The key idea is that all cryptographic operations are performed within the secure key storage without exposing the private key.
| typedef struct CBLKeyPair CBLKeyPair |
An opaque object representing the key pair.
| typedef struct CBLTLSIdentity CBLTLSIdentity |
An opaque object representing the TLSIdentity.
| enum CBLKeyUsages : uint16_t |
| enum CBLSignatureDigestAlgorithm : int |
| _cbl_warn_unused CBLCert *_cbl_nullable CBLCert_CertNextInChain | ( | CBLCert * | cert | ) |
Gets the next certificate in the chain if presents.
| cert | The current certificate. |
| _cbl_warn_unused CBLCert *_cbl_nullable CBLCert_CreateWithData | ( | FLSlice | certData, |
| CBLError *_cbl_nullable | outError ) |
Creates a CBLCert from X.509 certificate data in DER or PEM format.
| certData | The certificate data in DER or PEM format. |
| outError | On failure, the error will be written here. |
| _cbl_warn_unused FLSliceResult CBLCert_Data | ( | CBLCert * | cert, |
| bool | pemEncoded ) |
Returns the X.509 certificate data in either DER or PEM format.
| cert | The certificate. |
| pemEncoded | If true, returns the data in PEM format; otherwise, returns DER format. |
| _cbl_warn_unused CBLKeyPair * CBLCert_PublicKey | ( | CBLCert * | ) |
Returns a certificate's public key.
|
inlinestatic |
|
inlinestatic |
| _cbl_warn_unused FLSliceResult CBLCert_SubjectName | ( | CBLCert * | cert | ) |
Returns the certificate's Subject Name, which identifies the cert's owner.
This is an X.509 structured string consisting of "KEY=VALUE" pairs separated by commas, where the keys are attribute names. (Commas in values are backslash-escaped.)
| cert | The certificate. |
| _cbl_warn_unused FLSliceResult CBLCert_SubjectNameComponent | ( | CBLCert * | cert, |
| FLString | attributeKey ) |
Returns a component of the certificate's subject name that matches the specified attribute key.
| cert | The certificate. |
| attributeKey | The subject name attribute key to look for |
| void CBLCert_ValidTimespan | ( | CBLCert * | cert, |
| CBLTimestamp *_cbl_nullable | outCreated, | ||
| CBLTimestamp *_cbl_nullable | outExpires ) |
Returns the time range during which a certificate is valid.
| cert | The certificate. |
| outCreated | On return, the date/time the cert became valid (was signed). |
| outExpires | On return, the date/time at which the certificate expires. |
| _cbl_warn_unused CBLKeyPair *_cbl_nullable CBLKeyPair_CreateWithExternalKey | ( | size_t | keySizeInBits, |
| void * | externalKey, | ||
| CBLExternalKeyCallbacks | callbacks, | ||
| CBLError *_cbl_nullable | outError ) |
Returns an RSA key pair object that wraps an external key pair managed by application code.
All private key operations (signing and decryption) are delegated to the specified callbacks.
| keySizeInBits | The size of the RSA key in bits (e.g., 2048 or 4096). |
| externalKey | An opaque pointer that will be passed to the callbacks. Typically a pointer to your own external key object. |
| callbacks | A set of callback functions used to perform cryptographic operations using the external key. |
| outError | On failure, the error will be written here. |
| _cbl_warn_unused CBLKeyPair *_cbl_nullable CBLKeyPair_CreateWithPrivateKeyData | ( | FLSlice | privateKeyData, |
| FLSlice | passwordOrNull, | ||
| CBLError *_cbl_nullable | outError ) |
Creates an RSA KeyPair from private key data in PEM or DER format.
| privateKeyData | The private key data in either PEM or DER format. |
| passwordOrNull | The password used to decrypt the key, or NULL if the key is not encrypted. |
| outError | On failure, the error will be written here. |
| _cbl_warn_unused FLSliceResult CBLKeyPair_PrivateKeyData | ( | CBLKeyPair * | keyPair | ) |
Returns the private key data in DER format, if the private key is known and its data is accessible.
| keyPair | The key pair containing the private key. |
| _cbl_warn_unused FLSliceResult CBLKeyPair_PublicKeyData | ( | CBLKeyPair * | keyPair | ) |
Returns the public key data.
| keyPair | The key pair from which to retrieve the public key. |
| _cbl_warn_unused FLSliceResult CBLKeyPair_PublicKeyDigest | ( | CBLKeyPair * | keyPair | ) |
Returns a hex-encoded digest of the public key.
| keyPair | The key pair from which to extract the public key digest. |
|
inlinestatic |
|
inlinestatic |
| _cbl_warn_unused CBLCert * CBLTLSIdentity_Certificates | ( | CBLTLSIdentity * | identity | ) |
Returns the certificate chain associated with the given TLS identity.
| identity | The TLS identity. |
| _cbl_warn_unused CBLTLSIdentity *_cbl_nullable CBLTLSIdentity_CreateIdentity | ( | CBLKeyUsages | keyUsages, |
| FLDict | attributes, | ||
| int64_t | validityInMilliseconds, | ||
| FLString | label, | ||
| CBLError *_cbl_nullable | outError ) |
Creates a self-signed TLS identity using the specified certificate attributes.
If a non-NULL label (kFLSliceNull indicates NULL) is provided, the identity will be persisted in the platform's secure key store (Keychain on Apple platforms or CNG Key Storage Provider on Windows).
| keyUsages | The key usages for the generated identity. |
| attributes | A dictionary containing the certificate attributes. |
| validityInMilliseconds | Certificate validity duration in milliseconds. |
| label | The label used for persisting the identity in the platform's secure storage. If kFLSliceNull is passed, the identity will not be persisted. |
| outError | On failure, the error will be written here. |
| _cbl_warn_unused CBLTLSIdentity *_cbl_nullable CBLTLSIdentity_CreateIdentityWithKeyPair | ( | CBLKeyUsages | keyUsages, |
| CBLKeyPair * | keypair, | ||
| FLDict | attributes, | ||
| int64_t | validityInMilliseconds, | ||
| CBLError *_cbl_nullable | outError ) |
Creates a self-signed TLS identity using the provided RSA key pair and certificate attributes.
| keyUsages | The key usages for the generated identity. |
| keypair | The RSA key pair to be used for generating the TLS identity. |
| attributes | A dictionary containing the certificate attributes. |
| validityInMilliseconds | Certificate validity duration in milliseconds. |
| outError | On failure, the error will be written here. |
| bool CBLTLSIdentity_DeleteIdentityWithLabel | ( | FLString | label, |
| CBLError *_cbl_nullable | outError ) |
Deletes the TLS identity associated with the given persistent label from the platform's keystore (Keychain on Apple platforms or CNG Key Storage Provider on Windows).
| label | The persistent label associated with the identity to be deleted. |
| outError | On failure, the error will be written here. |
| CBLTimestamp CBLTLSIdentity_Expiration | ( | CBLTLSIdentity * | identity | ) |
Returns the date/time at which the first certificate in the chain expires.
Returns the expiration date/time of the first certificate in the chain.
| identity | The identity. |
| _cbl_warn_unused CBLTLSIdentity *_cbl_nullable CBLTLSIdentity_IdentityWithCerts | ( | CBLCert * | cert, |
| CBLError *_cbl_nullable | outError ) |
Returns an existing TLS identity associated with the provided certificate chain in the keystore (Keychain for Apple or CNG Key Storage Provider for Windows).
The keypair will be looked up by the first certificate in the chain.
| cert | A CBLCert instance representing the certificate chain. |
| outError | On failure, the error will be written here. |
| _cbl_warn_unused CBLTLSIdentity *_cbl_nullable CBLTLSIdentity_IdentityWithKeyPairAndCerts | ( | CBLKeyPair * | keypair, |
| CBLCert * | cert, | ||
| CBLError *_cbl_nullable | outError ) |
Returns a TLS identity from an existing identity using the provided RSA keypair and certificate chain.
The certificate chain is used as-is; the leaf certificate is not re-signed.
| keypair | A CBLKeyPair instance representing the RSA keypair to be associated with the identity. |
| cert | A CBLCert instance representing the certificate chain. |
| outError | On failure, the error will be written here. |
| _cbl_warn_unused CBLTLSIdentity *_cbl_nullable CBLTLSIdentity_IdentityWithLabel | ( | FLString | label, |
| CBLError *_cbl_nullable | outError ) |
Retrieves a TLS identity associated with the given persistent label from the platform's keystore (Keychain on Apple platforms or CNG Key Storage Provider on Windows).
| label | The persistent label associated with the identity to be deleted. |
| outError | On failure, the error will be written here. |
|
inlinestatic |
|
inlinestatic |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |