• BlackBerry Dynamics
  • Runtime library for iOS applications
  • 10.2.0.83
GDCryptoKeyStore.h
Go to the documentation of this file.
1 /*
2  * (c) 2019 BlackBerry Limited. All rights reserved.
3  */
4 
5 #pragma once
6 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 #ifndef GD_C_API
16 # if !defined(_WIN32)
17 # define GD_C_API __attribute__((visibility("default")))
18 # else
19 # define GD_C_API
20 # endif
21 #endif
22 
23 #ifndef GD_C_API_EXT
24 # define GD_C_API_EXT
25 #endif
26 
27 #include <stddef.h>
28 
35 GD_C_API int GDFIPS_mode(void);
36 
40 struct GD_C_API GDX509;
41 
47 GD_C_API struct GDX509* GDX509_copy(const struct GDX509* cert);
48 
54 GD_C_API void GDX509_free(struct GDX509* cert);
55 
59 struct GD_C_API GDX509List;
60 
64 struct GD_C_API GDDigest;
65 
70 struct GD_C_API GDDigestContext;
71 
79 struct GD_C_API GDX509List* GDX509List_read(const char* pem, int pem_length);
80 
87 struct GD_C_API GDX509List* GDX509List_copy(const struct GDX509List* certs);
88 
95 GD_C_API int GDX509List_num(const struct GDX509List* certs);
96 
104 GD_C_API const struct GDX509* GDX509List_value(const struct GDX509List* certs, int index);
105 
114 GD_C_API void GDX509List_insert(const struct GDX509List* certs, int index, const struct GDX509* cert);
115 
130 GD_C_API bool GDX509List_evaluate(const struct GDX509List* certs, const struct GDX509List* not_used, const char* hostname, char** reason);
131 
137 struct GD_C_API GDX509List* GDX509List_trusted_authorities(void);
138 
144 GD_C_API struct GDX509List* GDX509List_all_user_certs(void);
145 
151 GD_C_API struct GDX509List* GDX509List_valid_user_signing_certs(void);
152 
159 GD_C_API struct GDX509List* GDX509List_valid_user_encryption_certs(void);
160 
167 GD_C_API struct GDX509List* GDX509List_all_user_encryption_certs(void);
168 
175 GD_C_API struct GDX509List* GDX509List_aux_certs(const struct GDX509* cert);
176 
182 GD_C_API void GDX509List_free(struct GDX509List* certs);
183 
190 struct GD_C_API GDKey;
191 
195 struct GD_C_API GDKeyContext;
196 
201 GD_C_API extern const int GDKEY_TYPE_RSA;
202 
207 GD_C_API extern const int GDKEY_TYPE_DSA;
208 
213 GD_C_API extern const int GDKEY_TYPE_EC;
214 
221 GD_C_API struct GDKey* GDKey_public(const struct GDX509* cert);
222 
230 GD_C_API struct GDKey* GDKey_private(const struct GDX509* cert);
231 
237 GD_C_API void GDKey_free(struct GDKey* key);
238 
246 GD_C_API int GDKey_compare(const struct GDKey* a, const struct GDKey* b);
247 
255 GD_C_API int GDKey_size(const struct GDKey* key);
256 
263 GD_C_API int GDKey_bits(const struct GDKey* key);
264 
271 GD_C_API int GDKey_type(const struct GDKey* key);
272 
279 GD_C_API const char* GDKey_name(const struct GDKey* key);
280 
287 GD_C_API struct GDKeyContext* GDKeyContext_new(struct GDKey* key);
288 
295 GD_C_API struct GDKeyContext* GDKeyContext_copy(struct GDKeyContext* ctx);
296 
302 GD_C_API void GDKeyContext_free(struct GDKeyContext* ctx);
303 
310 GD_C_API int GDKey_sign_init(struct GDKeyContext* ctx);
311 
324 GD_C_API int GDKey_sign(struct GDKeyContext* ctx, void* signature, size_t* signature_length, const void* message, size_t message_length);
325 
332 GD_C_API int GDKey_verify_init(struct GDKeyContext* ctx);
333 
345 GD_C_API int GDKey_verify(struct GDKeyContext* ctx, const void* signature, size_t signature_length, const void* message, size_t message_length);
346 
353 GD_C_API int GDKey_encrypt_init(struct GDKeyContext* ctx);
354 
365 GD_C_API int GDKey_encrypt(struct GDKeyContext* ctx, void* encrypted, size_t* encrypted_length, const void* clear, size_t clear_length);
366 
373 GD_C_API int GDKey_decrypt_init(struct GDKeyContext* ctx);
374 
385 GD_C_API int GDKey_decrypt(struct GDKeyContext* ctx, void* clear, size_t* clear_length, const void* encrypted, size_t encrypted_length);
386 
396 GD_C_API int GDKey_sign_final(struct GDDigestContext* digest, void* signature, unsigned int* signature_length, struct GDKey* key);
397 
408 GD_C_API int GDKey_verify_final(struct GDDigestContext* digest, const void* signature, unsigned int signature_length, struct GDKey* key);
409 
417 GD_C_API int GDKey_set_signature_md(struct GDKeyContext* ctx, const struct GDDigest* digest);
418 
426 GD_C_API int GDKey_get_signature_md(struct GDKeyContext* ctx, const struct GDDigest** digest);
427 
428 #ifdef __cplusplus
429 }
430 #endif
431 
GDKey_sign_init
int GDKey_sign_init(struct GDKeyContext *ctx)
Initialize a key context for signing.
GDKey_encrypt_init
int GDKey_encrypt_init(struct GDKeyContext *ctx)
Initialize a key context for encryption.
GDKey_decrypt
int GDKey_decrypt(struct GDKeyContext *ctx, void *clear, size_t *clear_length, const void *encrypted, size_t encrypted_length)
Decrypt data.
GDX509List_insert
void GDX509List_insert(const struct GDX509List *certs, int index, const struct GDX509 *cert)
Insert a certificate into the list.
GDKey_encrypt
int GDKey_encrypt(struct GDKeyContext *ctx, void *encrypted, size_t *encrypted_length, const void *clear, size_t clear_length)
Encrypt data.
GDKey_public
struct GDKey * GDKey_public(const struct GDX509 *cert)
Retrieve the public key.
GDX509List_valid_user_signing_certs
struct GDX509List * GDX509List_valid_user_signing_certs(void)
Retrieve all valid user certificates managed by Dynamics.
GDX509_copy
struct GDX509 * GDX509_copy(const struct GDX509 *cert)
Copy a X509 structure.
GDKey_set_signature_md
int GDKey_set_signature_md(struct GDKeyContext *ctx, const struct GDDigest *digest)
Sets the message digest type used in a signature.
GDKey_type
int GDKey_type(const struct GDKey *key)
Key type.
GDX509List_evaluate
bool GDX509List_evaluate(const struct GDX509List *certs, const struct GDX509List *not_used, const char *hostname, char **reason)
Evaluate a certificate chain.
GDX509List_all_user_encryption_certs
struct GDX509List * GDX509List_all_user_encryption_certs(void)
Retrieve all user encryption certificates managed by Dynamics.
GDX509List_trusted_authorities
struct GDX509List * GDX509List_trusted_authorities(void)
Retrieve a list of trusted X509 certificate authorities.
GDX509List_aux_certs
struct GDX509List * GDX509List_aux_certs(const struct GDX509 *cert)
Retrieve a certificate chain for a user certificate.
GDKey_private
struct GDKey * GDKey_private(const struct GDX509 *cert)
Retrieve an opaque private key corresponding to a user certificate.
GDKey_get_signature_md
int GDKey_get_signature_md(struct GDKeyContext *ctx, const struct GDDigest **digest)
Returns the message digest type.
GDKey_compare
int GDKey_compare(const struct GDKey *a, const struct GDKey *b)
Compare two keys.
GDKey_bits
int GDKey_bits(const struct GDKey *key)
Key size.
GDKey_sign_final
int GDKey_sign_final(struct GDDigestContext *digest, void *signature, unsigned int *signature_length, struct GDKey *key)
Sign a digest.
GDKey_verify_init
int GDKey_verify_init(struct GDKeyContext *ctx)
Initialize a key context for verification.
GDX509List_value
const struct GDX509 * GDX509List_value(const struct GDX509List *certs, int index)
Retrieve an X509 certificate from a list.
GDX509List_read
struct GDX509List * GDX509List_read(const char *pem, int pem_length)
Retrieve a list of X509 certificates within a PEM container.
GDKey_decrypt_init
int GDKey_decrypt_init(struct GDKeyContext *ctx)
Initialize a key context for decryption.
GDDigest
int GDDigest(const void *data, size_t data_sz, void *md, unsigned int *md_sz, const struct GDDigest *type)
Calculate a digest.
GDX509List_num
int GDX509List_num(const struct GDX509List *certs)
Count the number of X509 certificates.
GDKey_free
void GDKey_free(struct GDKey *key)
Free a key structure.
GDX509List_free
void GDX509List_free(struct GDX509List *certs)
Free a X509 list structure.
GDFIPS_mode
int GDFIPS_mode(void)
Retrieve the current FIPS 140-2 mode of operation.
GDKEY_TYPE_DSA
const int GDKEY_TYPE_DSA
DSA key type.
GDX509List_all_user_certs
struct GDX509List * GDX509List_all_user_certs(void)
Retrieve all user certificates managed by Dynamics.
GDKey_verify_final
int GDKey_verify_final(struct GDDigestContext *digest, const void *signature, unsigned int signature_length, struct GDKey *key)
Verify a digest.
GDX509List_copy
struct GDX509List * GDX509List_copy(const struct GDX509List *certs)
Copy a list of X509 certificates.
GDKey_name
const char * GDKey_name(const struct GDKey *key)
Return the key algorithm name.
GDX509_free
void GDX509_free(struct GDX509 *cert)
Free a X509 structure.
GDKey_verify
int GDKey_verify(struct GDKeyContext *ctx, const void *signature, size_t signature_length, const void *message, size_t message_length)
Verify a signed message.
GDKey_size
int GDKey_size(const struct GDKey *key)
Signature size.
GDKEY_TYPE_RSA
const int GDKEY_TYPE_RSA
RSA key type.
GDKeyContext_copy
struct GDKeyContext * GDKeyContext_copy(struct GDKeyContext *ctx)
Copy a key context.
GDKeyContext_free
void GDKeyContext_free(struct GDKeyContext *ctx)
Free a key context.
GDX509List_valid_user_encryption_certs
struct GDX509List * GDX509List_valid_user_encryption_certs(void)
Retrieve all valid user encryption certificates managed by Dynamics.
GDKeyContext_new
struct GDKeyContext * GDKeyContext_new(struct GDKey *key)
Create a new key context.
GDKEY_TYPE_EC
const int GDKEY_TYPE_EC
EC key type.
GDKey_sign
int GDKey_sign(struct GDKeyContext *ctx, void *signature, size_t *signature_length, const void *message, size_t message_length)
Sign a message.