• BlackBerry Dynamics
  • Runtime library for iOS applications
  • 10.2.0.83
GDCryptoAlgorithms.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 "GDCryptoKeyStore.h"
28 #include "GDCryptoError.h"
29 #include <stddef.h>
30 
34 GD_C_API extern const int GDCIPHER_MAX_BLOCK_LENGTH;
35 
39 GD_C_API extern const int GDCIPHER_MAX_KEY_LENGTH;
40 
43 GD_C_API extern const unsigned long GDCIPHER_STREAM_CIPHER;
44 
47 GD_C_API extern const unsigned long GDCIPHER_ECB_MODE;
48 
51 GD_C_API extern const unsigned long GDCIPHER_CBC_MODE;
52 
55 GD_C_API extern const unsigned long GDCIPHER_CFB_MODE;
56 
59 GD_C_API extern const unsigned long GDCIPHER_OFB_MODE;
60 
63 GD_C_API extern const unsigned long GDCIPHER_CTR_MODE;
64 
67 GD_C_API extern const unsigned long GDCIPHER_GCM_MODE;
68 
71 GD_C_API extern const unsigned long GDCIPHER_CCM_MODE;
72 
75 GD_C_API extern const unsigned long GDCIPHER_XTS_MODE;
76 
79 GD_C_API extern const unsigned long GDCIPHER_WRAP_MODE;
80 
84 struct GD_C_API GDCipher;
85 
89 struct GD_C_API GDCipherContext;
90 
96 GD_C_API const char** GDCipher_list(void);
97 
105 GD_C_API const struct GDCipher* GDCipher_byname(const char* name);
106 
114 GD_C_API const char* GDCipher_name(const struct GDCipherContext* ctx);
115 
122 GD_C_API const struct GDCipher* GDCipher_bycontext(const struct GDCipherContext* ctx);
123 
130 GD_C_API int GDCipher_block_size(const struct GDCipher* cipher);
131 
138 GD_C_API int GDCipher_key_length(const struct GDCipher* cipher);
139 
146 GD_C_API int GDCipher_iv_length(const struct GDCipher* cipher);
147 
154 GD_C_API unsigned long GDCipher_mode(const struct GDCipher* cipher);
155 
162 GD_C_API void GDCipher_set_padding(struct GDCipherContext* ctx, int padding);
163 
170 GD_C_API struct GDCipherContext* GDCipher_new(void);
171 
182 GD_C_API int GDCipher_init(struct GDCipherContext* ctx, const struct GDCipher* cipher, const void* key, const void* iv, int mode);
183 
192 GD_C_API int GDCipher_copy(struct GDCipherContext* destination, const struct GDCipherContext* source);
193 
206 GD_C_API int GDCipher_update(struct GDCipherContext* ctx, void* out_data, int* out_data_sz, const void* in_data, int in_data_sz);
207 
217 GD_C_API int GDCipher_final(struct GDCipherContext* ctx, void* out_data, int* out_sz);
218 
229 GD_C_API int GDCipher(struct GDCipherContext* ctx, void* out_data, const void* in_data, unsigned int in_data_sz);
230 
239 GD_C_API int GDCipher_cleanup(struct GDCipherContext* ctx);
240 
247 GD_C_API void GDCipher_free(struct GDCipherContext* ctx);
248 
252 struct GD_C_API GDDigest;
253 
258 struct GD_C_API GDDigestContext;
259 
267 GD_C_API const struct GDDigest* GDDigest_byname(const char *name);
268 
276 GD_C_API const char* GDDigest_name(const struct GDDigestContext* ctx);
277 
284 GD_C_API const struct GDDigest* GDDigest_bycontext(const struct GDDigestContext* ctx);
285 
290 GD_C_API extern const int GDDIGEST_MAX_SIZE;
291 
298 GD_C_API int GDDigest_size(const struct GDDigest* digest);
299 
306 GD_C_API int GDDigest_block_size(const struct GDDigest* digest);
307 
314 GD_C_API struct GDDigestContext* GDDigest_new(void);
315 
323 GD_C_API int GDDigest_init(struct GDDigestContext* ctx, const struct GDDigest* algorithm);
324 
333 GD_C_API int GDDigest_copy(struct GDDigestContext* destination, const struct GDDigestContext* source);
334 
344 GD_C_API int GDDigest_update(struct GDDigestContext* ctx, const void* message, size_t message_sz);
345 
356 GD_C_API int GDDigest_final(struct GDDigestContext* ctx, void* digest, unsigned int* digest_sz);
357 
368 GD_C_API int GDDigest(const void* data, size_t data_sz, void* md, unsigned int* md_sz, const struct GDDigest* type);
369 
379 GD_C_API int GDDigest_sign_init(struct GDDigestContext* ctx, struct GDKeyContext** key_context, const struct GDDigest* digest, struct GDKey* key);
380 
389 GD_C_API int GDDigest_sign_final(struct GDDigestContext* ctx, void* signature, size_t* signature_sz);
390 
400 GD_C_API int GDDigest_verify_init(struct GDDigestContext* ctx, struct GDKeyContext** key_ctx, const struct GDDigest* digest, struct GDKey* key);
401 
411 GD_C_API int GDDigest_verify_final(struct GDDigestContext* ctx, const void* signature, size_t signature_sz);
412 
421 GD_C_API int GDDigest_cleanup(struct GDDigestContext* ctx);
422 
427 GD_C_API void GDDigest_free(struct GDDigestContext* ctx);
428 
429 #ifdef __cplusplus
430 }
431 #endif
432 
GDDigest_block_size
int GDDigest_block_size(const struct GDDigest *digest)
Return the digest block size.
GDDigest_verify_init
int GDDigest_verify_init(struct GDDigestContext *ctx, struct GDKeyContext **key_ctx, const struct GDDigest *digest, struct GDKey *key)
Initialize a digest context for verification.
GDCipher_mode
unsigned long GDCipher_mode(const struct GDCipher *cipher)
Return the cipher mode.
GDCIPHER_OFB_MODE
const unsigned long GDCIPHER_OFB_MODE
OFB cipher mode.
GDCipher_cleanup
int GDCipher_cleanup(struct GDCipherContext *ctx)
Clears all information from a cipher context.
GDDigest_copy
int GDDigest_copy(struct GDDigestContext *destination, const struct GDDigestContext *source)
Copy a digest context.
GDDigest_free
void GDDigest_free(struct GDDigestContext *ctx)
Free the digest context.
GDDigest_sign_init
int GDDigest_sign_init(struct GDDigestContext *ctx, struct GDKeyContext **key_context, const struct GDDigest *digest, struct GDKey *key)
Initialize a digest context for signing.
GDCIPHER_STREAM_CIPHER
const unsigned long GDCIPHER_STREAM_CIPHER
Stream cipher mode.
GDDigest_final
int GDDigest_final(struct GDDigestContext *ctx, void *digest, unsigned int *digest_sz)
Finalize and output the digest.
GDDigest_init
int GDDigest_init(struct GDDigestContext *ctx, const struct GDDigest *algorithm)
Initialize a digest context.
GDCryptoKeyStore.h
GDCipher_final
int GDCipher_final(struct GDCipherContext *ctx, void *out_data, int *out_sz)
Encipher or decipher last block.
GDCIPHER_XTS_MODE
const unsigned long GDCIPHER_XTS_MODE
XTS cipher mode.
GDDigest_byname
const struct GDDigest * GDDigest_byname(const char *name)
Return a digest algorithm by name.
GDDigest_name
const char * GDDigest_name(const struct GDDigestContext *ctx)
Return a digest's name.
GDCIPHER_MAX_BLOCK_LENGTH
const int GDCIPHER_MAX_BLOCK_LENGTH
Maximum block length for all ciphers.
GDCipher_name
const char * GDCipher_name(const struct GDCipherContext *ctx)
Return a cipher suite's name.
GDCIPHER_WRAP_MODE
const unsigned long GDCIPHER_WRAP_MODE
Wrap cipher mode.
GDCipher_set_padding
void GDCipher_set_padding(struct GDCipherContext *ctx, int padding)
Enable or disable padding.
GDDigest_bycontext
const struct GDDigest * GDDigest_bycontext(const struct GDDigestContext *ctx)
Return a digest by context.
GDDigest_size
int GDDigest_size(const struct GDDigest *digest)
Size of a digest in bytes.
GDDigest
int GDDigest(const void *data, size_t data_sz, void *md, unsigned int *md_sz, const struct GDDigest *type)
Calculate a digest.
GDCipher_byname
const struct GDCipher * GDCipher_byname(const char *name)
Return a cipher suite by name.
GDCIPHER_CCM_MODE
const unsigned long GDCIPHER_CCM_MODE
CCM cipher mode.
GDCipher_free
void GDCipher_free(struct GDCipherContext *ctx)
Free the cipher context.
GDCIPHER_CFB_MODE
const unsigned long GDCIPHER_CFB_MODE
CFB cipher mode.
GDCipher_new
struct GDCipherContext * GDCipher_new(void)
Return a new cipher context.
GDCipher_bycontext
const struct GDCipher * GDCipher_bycontext(const struct GDCipherContext *ctx)
Return a cipher by context.
GDCipher_block_size
int GDCipher_block_size(const struct GDCipher *cipher)
Return the cipher block size.
GDCipher_iv_length
int GDCipher_iv_length(const struct GDCipher *cipher)
Return the IV length.
GDCIPHER_GCM_MODE
const unsigned long GDCIPHER_GCM_MODE
GCM cipher mode.
GDCIPHER_CTR_MODE
const unsigned long GDCIPHER_CTR_MODE
CTR cipher mode.
GDCIPHER_ECB_MODE
const unsigned long GDCIPHER_ECB_MODE
ECB cipher mode.
GDCipher_copy
int GDCipher_copy(struct GDCipherContext *destination, const struct GDCipherContext *source)
Copy a cipher context.
GDDigest_sign_final
int GDDigest_sign_final(struct GDDigestContext *ctx, void *signature, size_t *signature_sz)
Sign a digest.
GDDigest_update
int GDDigest_update(struct GDDigestContext *ctx, const void *message, size_t message_sz)
Calculate a digest.
GDDigest_verify_final
int GDDigest_verify_final(struct GDDigestContext *ctx, const void *signature, size_t signature_sz)
Verify a digest.
GDCIPHER_MAX_KEY_LENGTH
const int GDCIPHER_MAX_KEY_LENGTH
Maximum key length for all ciphers.
GDCipher
int GDCipher(struct GDCipherContext *ctx, void *out_data, const void *in_data, unsigned int in_data_sz)
Encipher or decipher.
GDCipher_update
int GDCipher_update(struct GDCipherContext *ctx, void *out_data, int *out_data_sz, const void *in_data, int in_data_sz)
Encipher or decipher.
GDDIGEST_MAX_SIZE
const int GDDIGEST_MAX_SIZE
Maximum supported digest size in bytes.
GDCipher_key_length
int GDCipher_key_length(const struct GDCipher *cipher)
Return the cipher key length.
GDDigest_new
struct GDDigestContext * GDDigest_new(void)
Return a new digest context.
GDDigest_cleanup
int GDDigest_cleanup(struct GDDigestContext *ctx)
Clears all information from a digest context.
GDCryptoError.h
GDCIPHER_CBC_MODE
const unsigned long GDCIPHER_CBC_MODE
CBC cipher mode.
GDCipher_init
int GDCipher_init(struct GDCipherContext *ctx, const struct GDCipher *cipher, const void *key, const void *iv, int mode)
Initialize a cipher context.
GDCipher_list
const char ** GDCipher_list(void)
Return all cipher suites by name.