wickr-crypto-c
openssl_suite.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 openssl_suite_h
23 #define openssl_suite_h
24 
25 #include <stdlib.h>
26 #include <stdio.h>
27 #include "buffer.h"
28 #include "cipher.h"
29 #include "crypto_engine.h"
30 #include "ecdsa.h"
31 #include "eckey.h"
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
48 
59 
75  const wickr_buffer_t *aad,
76  const wickr_cipher_key_t *key,
77  const wickr_buffer_t *iv);
78 
92  const wickr_buffer_t *aad,
93  const wickr_cipher_key_t *key,
94  bool only_auth_ciphers);
95 
109  const wickr_buffer_t *salt,
110  wickr_digest_t mode);
111 
122 
132 wickr_ec_key_t *openssl_ec_key_import(const wickr_buffer_t *buffer, bool is_private);
133 
146  const wickr_buffer_t *data_to_sign,
147  wickr_digest_t digest_mode);
148 
159 bool openssl_ec_verify(const wickr_ecdsa_result_t *signature,
160  const wickr_ec_key_t *ec_public_key,
161  const wickr_buffer_t *data_to_verify);
162 
173 
174 
186  const wickr_buffer_t *hmac_key,
187  wickr_digest_t mode);
188 
200 bool openssl_hmac_verify(const wickr_buffer_t *data,
201  const wickr_buffer_t *hmac_key,
202  wickr_digest_t mode,
203  const wickr_buffer_t *expected);
204 
216 wickr_buffer_t *openssl_hkdf(const wickr_buffer_t *input_key_material,
217  const wickr_buffer_t *salt,
218  const wickr_buffer_t *info,
219  wickr_digest_t hash_mode);
220 
230 wickr_buffer_t *openssl_sha2_file(FILE *in_file, wickr_digest_t mode);
231 
242 bool openssl_encrypt_file(FILE *in_file, const wickr_cipher_key_t *key, FILE *out_file);
243 
259 bool openssl_decrypt_file(FILE *in_file,
260  const wickr_cipher_key_t *key,
261  FILE *out_file,
262  bool only_auth_ciphers);
263 
271 bool openssl_enable_fips_mode(void);
272 
281 
282 /* Functions to assist with testing */
283 wickr_ec_key_t *openssl_ec_key_import_test_key(wickr_ec_curve_t curve, const char *priv_hex);
284 
285 #ifdef __cplusplus
286 }
287 #endif
288 
289 #endif /* openssl_suite_h */
bool openssl_enable_fips_mode(void)
bool openssl_encrypt_file(FILE *in_file, const wickr_cipher_key_t *key, FILE *out_file)
Representation of public and private Elliptic Curve Keypair information as buffers.
Definition: eckey.h:90
wickr_buffer_t * openssl_sha2(const wickr_buffer_t *buffer, const wickr_buffer_t *salt, wickr_digest_t mode)
wickr_buffer_t * openssl_gen_shared_secret(const wickr_ec_key_t *local, const wickr_ec_key_t *peer)
bool openssl_decrypt_file(FILE *in_file, const wickr_cipher_key_t *key, FILE *out_file, bool only_auth_ciphers)
Represents an array of bytes and the length of the allocation associated with those bytes.
Definition: buffer.h:51
bool openssl_is_fips_supported()
bool openssl_ec_verify(const wickr_ecdsa_result_t *signature, const wickr_ec_key_t *ec_public_key, const wickr_buffer_t *data_to_verify)
Represents a cipher that can be used in the crypto_engine. This meta object holds parameters for the ...
Definition: cipher.h:56
wickr_cipher_result_t * openssl_aes256_encrypt(const wickr_buffer_t *plaintext, const wickr_buffer_t *aad, const wickr_cipher_key_t *key, const wickr_buffer_t *iv)
Elliptic Curve Digital Signature Algorithm Result.
Definition: ecdsa.h:54
wickr_buffer_t * openssl_crypto_random(size_t len)
bool openssl_hmac_verify(const wickr_buffer_t *data, const wickr_buffer_t *hmac_key, wickr_digest_t mode, const wickr_buffer_t *expected)
wickr_ec_key_t * openssl_ec_key_import(const wickr_buffer_t *buffer, bool is_private)
wickr_buffer_t * openssl_hkdf(const wickr_buffer_t *input_key_material, const wickr_buffer_t *salt, const wickr_buffer_t *info, wickr_digest_t hash_mode)
Definition: cipher.h:97
Definition: cipher.h:189
wickr_ec_key_t * openssl_ec_rand_key(wickr_ec_curve_t curve)
wickr_buffer_t * openssl_hmac_create(const wickr_buffer_t *data, const wickr_buffer_t *hmac_key, wickr_digest_t mode)
wickr_ecdsa_result_t * openssl_ec_sign(const wickr_ec_key_t *ec_signing_key, const wickr_buffer_t *data_to_sign, wickr_digest_t digest_mode)
wickr_buffer_t * openssl_aes256_decrypt(const wickr_cipher_result_t *cipher_result, const wickr_buffer_t *aad, const wickr_cipher_key_t *key, bool only_auth_ciphers)
wickr_cipher_key_t * openssl_cipher_key_random(wickr_cipher_t cipher)
wickr_buffer_t * openssl_sha2_file(FILE *in_file, wickr_digest_t mode)
Digest function parameters.
Definition: digest.h:54
Metadata about curve types to help with key generation, and signatures.
Definition: eckey.h:65