wickr-crypto-c
crypto_engine.h
1 /*
2  * Copyright © 2012-2018 Wickr Inc. All rights reserved.
3  *
4  * This code is being released for EDUCATIONAL, ACADEMIC, AND CODE REVIEW PURPOSES
5  * ONLY. COMMERCIAL USE OF THE CODE IS EXPRESSLY PROHIBITED. For additional details,
6  * please see LICENSE
7  *
8  * THE CODE IS MADE AVAILABLE "AS-IS" AND WITHOUT ANY EXPRESS OR
9  * IMPLIED GUARANTEES AS TO FITNESS, MERCHANTABILITY, NON-
10  * INFRINGEMENT OR OTHERWISE. IT IS NOT BEING PROVIDED IN TRADE BUT ON
11  * A VOLUNTARY BASIS ON BEHALF OF THE AUTHOR’S PART FOR THE BENEFIT
12  * OF THE LICENSEE AND IS NOT MADE AVAILABLE FOR CONSUMER USE OR ANY
13  * OTHER USE OUTSIDE THE TERMS OF THIS LICENSE. ANYONE ACCESSING THE
14  * CODE SHOULD HAVE THE REQUISITE EXPERTISE TO SECURE THEIR SYSTEM
15  * AND DEVICES AND TO ACCESS AND USE THE CODE FOR REVIEW PURPOSES
16  * ONLY. LICENSEE BEARS THE RISK OF ACCESSING AND USING THE CODE. IN
17  * PARTICULAR, AUTHOR BEARS NO LIABILITY FOR ANY INTERFERENCE WITH OR
18  * ADVERSE EFFECT THAT MAY OCCUR AS A RESULT OF THE LICENSEE
19  * ACCESSING AND/OR USING THE CODE ON LICENSEE’S SYSTEM.
20  */
21 
22 #ifndef crypto_engine_h
23 #define crypto_engine_h
24 
25 #include "buffer.h"
26 #include "cipher.h"
27 #include "digest.h"
28 #include "eckey.h"
29 #include "ecdsa.h"
30 #include "kdf.h"
31 
32 #include <stdlib.h>
33 #include <stdio.h>
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
54 
57 
66  wickr_buffer_t *(*wickr_crypto_engine_crypto_random)(size_t len);
67 
76  wickr_cipher_key_t *(*wickr_crypto_engine_cipher_key_random)(wickr_cipher_t cipher);
77 
91  wickr_cipher_result_t *(*wickr_crypto_engine_cipher_encrypt)(const wickr_buffer_t *plaintext,
92  const wickr_buffer_t *aad,
93  const wickr_cipher_key_t *key,
94  const wickr_buffer_t *iv);
95 
107  wickr_buffer_t *(*wickr_crypto_engine_cipher_decrypt)(const wickr_cipher_result_t *cipher_result,
108  const wickr_buffer_t *aad,
109  const wickr_cipher_key_t *key,
110  bool only_auth_ciphers);
111 
123  const char *sourceFilePath,
124  const char *destinationFilePath);
125 
139  const char *sourceFilePath,
140  const char *destinationFilePath,
141  bool only_auth_ciphers);
142 
154  wickr_buffer_t *(*wickr_crypto_engine_digest)(const wickr_buffer_t *buffer,
155  const wickr_buffer_t *salt,
156  wickr_digest_t digest_mode);
157 
167  wickr_buffer_t *(*wickr_crypto_engine_digest_file)(FILE *in_file,
168  const wickr_digest_t mode);
169 
178  wickr_ec_key_t *(*wickr_crypto_engine_ec_rand_key)(wickr_ec_curve_t curve);
179 
189  wickr_ec_key_t *(*wickr_crypto_engine_ec_key_import)(const wickr_buffer_t *buffer,
190  bool is_private);
191 
203  wickr_ecdsa_result_t *(*wickr_crypto_engine_ec_sign)(const wickr_ec_key_t *ec_signing_key,
204  const wickr_buffer_t *data_to_sign,
205  const wickr_digest_t digest_mode);
206 
218  const wickr_ec_key_t *ec_public_key,
219  const wickr_buffer_t *data_to_verify);
220 
230  wickr_buffer_t *(*wickr_crypto_engine_gen_shared_secret)(const wickr_ec_key_t *local, const wickr_ec_key_t *peer);
231 
242  wickr_buffer_t *(*wickr_crypto_engine_hmac_create)(const wickr_buffer_t *data,
243  const wickr_buffer_t *hmac_key,
244  wickr_digest_t digest_mode);
245 
258  const wickr_buffer_t *hmac_key,
259  const wickr_digest_t mode,
260  const wickr_buffer_t *expected);
261 
272  wickr_kdf_result_t *(*wickr_crypto_kdf_gen)(wickr_kdf_algo_t algo,
273  const wickr_buffer_t *passphrase);
274 
285  wickr_kdf_result_t *(*wickr_crypto_kdf_meta)(const wickr_kdf_meta_t *existing_meta,
286  const wickr_buffer_t *passphrase);
287 };
288 
290 
299 
320  wickr_kdf_algo_t algo,
321  wickr_cipher_t cipher,
322  const wickr_buffer_t *value,
323  const wickr_buffer_t *passphrase);
324 
334  const wickr_buffer_t *input_buffer,
335  const wickr_buffer_t *passphrase);
336 
351 
361 
376 
377 #ifdef __cplusplus
378 }
379 #endif
380 
381 #endif /* crypto_engine_h */
Represents the information the KDF function will need along with it's input to derive a particular ou...
Definition: kdf.h:135
wickr_buffer_t * wickr_crypto_engine_kdf_cipher(const wickr_crypto_engine_t *engine, wickr_kdf_algo_t algo, wickr_cipher_t cipher, const wickr_buffer_t *value, const wickr_buffer_t *passphrase)
Representation of public and private Elliptic Curve Keypair information as buffers.
Definition: eckey.h:90
bool(* wickr_crypto_engine_ec_verify)(const wickr_ecdsa_result_t *signature, const wickr_ec_key_t *ec_public_key, const wickr_buffer_t *data_to_verify)
Definition: crypto_engine.h:217
wickr_ec_curve_t default_curve
Definition: crypto_engine.h:55
const wickr_crypto_engine_t wickr_crypto_engine_get_default(void)
Represents an array of bytes and the length of the allocation associated with those bytes.
Definition: buffer.h:51
Represents the result of a KDF function execution.
Definition: kdf.h:155
Represents a cipher that can be used in the crypto_engine. This meta object holds parameters for the ...
Definition: cipher.h:56
Elliptic Curve Digital Signature Algorithm Result.
Definition: ecdsa.h:54
Metadata associated with a particular KDF function.
Definition: kdf.h:71
wickr_digest_t wickr_digest_matching_curve(wickr_ec_curve_t curve)
wickr_buffer_t * wickr_crypto_engine_kdf_decipher(const wickr_crypto_engine_t *engine, const wickr_buffer_t *input_buffer, const wickr_buffer_t *passphrase)
bool(* wickr_crypto_engine_encrypt_file)(const wickr_cipher_key_t *key, const char *sourceFilePath, const char *destinationFilePath)
Definition: crypto_engine.h:122
Definition: cipher.h:97
Definition: cipher.h:189
bool(* wickr_crypto_engine_decrypt_file)(const wickr_cipher_key_t *key, const char *sourceFilePath, const char *destinationFilePath, bool only_auth_ciphers)
Definition: crypto_engine.h:138
wickr_cipher_t wickr_exchange_cipher_matching_cipher(wickr_cipher_t cipher)
bool(* wickr_crypto_engine_hmac_verify)(const wickr_buffer_t *data, const wickr_buffer_t *hmac_key, const wickr_digest_t mode, const wickr_buffer_t *expected)
Definition: crypto_engine.h:257
wickr_cipher_t default_cipher
Definition: crypto_engine.h:56
Digest function parameters.
Definition: digest.h:54
Interface to a set of cryptographic operations used throughout the library. Currently the default imp...
Definition: crypto_engine.h:53
Metadata about curve types to help with key generation, and signatures.
Definition: eckey.h:65
wickr_digest_t wickr_digest_matching_cipher(wickr_cipher_t cipher)