Skip to content

Commit

Permalink
[CI] update code
Browse files Browse the repository at this point in the history
  • Loading branch information
Hacl Bot committed Nov 3, 2023
1 parent 4d3ac1c commit a9e8cc2
Show file tree
Hide file tree
Showing 357 changed files with 49,072 additions and 58,340 deletions.
6 changes: 3 additions & 3 deletions include/EverCrypt_Chacha20Poly1305.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ extern "C" {
#include "krml/lowstar_endianness.h"
#include "krml/internal/target.h"

#include "Hacl_Chacha20Poly1305_32.h"
#include "Hacl_Chacha20Poly1305_256.h"
#include "Hacl_Chacha20Poly1305_128.h"
#include "Hacl_AEAD_Chacha20Poly1305_Simd256.h"
#include "Hacl_AEAD_Chacha20Poly1305_Simd128.h"
#include "Hacl_AEAD_Chacha20Poly1305.h"
#include "EverCrypt_AutoConfig2.h"

void
Expand Down
5 changes: 3 additions & 2 deletions include/EverCrypt_HMAC.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ extern "C" {
#include "Hacl_Streaming_Types.h"
#include "Hacl_Krmllib.h"
#include "Hacl_Hash_SHA2.h"
#include "Hacl_Hash_Blake2.h"
#include "Hacl_Hash_Blake2s.h"
#include "Hacl_Hash_Blake2b.h"

bool EverCrypt_HMAC_is_supported_alg(Spec_Hash_Definitions_hash_alg uu___);

typedef Spec_Hash_Definitions_hash_alg EverCrypt_HMAC_supported_alg;

extern void (*EverCrypt_HMAC_hash_256)(uint8_t *x0, uint32_t x1, uint8_t *x2);
extern void (*EverCrypt_HMAC_hash_256)(uint8_t *x0, uint8_t *x1, uint32_t x2);

void
EverCrypt_HMAC_compute(
Expand Down
64 changes: 33 additions & 31 deletions include/EverCrypt_Hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,37 +39,38 @@ extern "C" {
#include "Hacl_Krmllib.h"
#include "Hacl_Hash_SHA3.h"
#include "Hacl_Hash_SHA2.h"
#include "Hacl_Hash_Blake2s_128.h"
#include "Hacl_Hash_Blake2b_256.h"
#include "Hacl_Hash_Blake2.h"
#include "Hacl_Hash_Blake2s_Simd128.h"
#include "Hacl_Hash_Blake2s.h"
#include "Hacl_Hash_Blake2b_Simd256.h"
#include "Hacl_Hash_Blake2b.h"
#include "EverCrypt_Error.h"
#include "EverCrypt_AutoConfig2.h"

typedef struct EverCrypt_Hash_state_s_s EverCrypt_Hash_state_s;

uint32_t EverCrypt_Hash_Incremental_hash_len(Spec_Hash_Definitions_hash_alg a);

typedef struct EverCrypt_Hash_Incremental_hash_state_s
typedef struct EverCrypt_Hash_Incremental_state_t_s
{
EverCrypt_Hash_state_s *block_state;
uint8_t *buf;
uint64_t total_len;
}
EverCrypt_Hash_Incremental_hash_state;
EverCrypt_Hash_Incremental_state_t;

/**
Allocate initial state for the agile hash. The argument `a` stands for the
choice of algorithm (see Hacl_Spec.h). This API will automatically pick the most
efficient implementation, provided you have called EverCrypt_AutoConfig2_init()
before. The state is to be freed by calling `free`.
*/
EverCrypt_Hash_Incremental_hash_state
*EverCrypt_Hash_Incremental_create_in(Spec_Hash_Definitions_hash_alg a);
EverCrypt_Hash_Incremental_state_t
*EverCrypt_Hash_Incremental_malloc(Spec_Hash_Definitions_hash_alg a);

/**
Reset an existing state to the initial hash state with empty data.
*/
void EverCrypt_Hash_Incremental_init(EverCrypt_Hash_Incremental_hash_state *s);
void EverCrypt_Hash_Incremental_reset(EverCrypt_Hash_Incremental_state_t *state);

/**
Feed an arbitrary amount of data into the hash. This function returns
Expand All @@ -80,34 +81,35 @@ algorithm. Both limits are unlikely to be attained in practice.
*/
EverCrypt_Error_error_code
EverCrypt_Hash_Incremental_update(
EverCrypt_Hash_Incremental_hash_state *s,
uint8_t *data,
uint32_t len
EverCrypt_Hash_Incremental_state_t *state,
uint8_t *chunk,
uint32_t chunk_len
);

/**
Perform a run-time test to determine which algorithm was chosen for the given piece of state.
*/
Spec_Hash_Definitions_hash_alg
EverCrypt_Hash_Incremental_alg_of_state(EverCrypt_Hash_Incremental_hash_state *s);
EverCrypt_Hash_Incremental_alg_of_state(EverCrypt_Hash_Incremental_state_t *s);

/**
Write the resulting hash into `dst`, an array whose length is
Write the resulting hash into `output`, an array whose length is
algorithm-specific. You can use the macros defined earlier in this file to
allocate a destination buffer of the right length. The state remains valid after
a call to `finish`, meaning the user may feed more data into the hash via
a call to `digest`, meaning the user may feed more data into the hash via
`update`. (The finish function operates on an internal copy of the state and
therefore does not invalidate the client-held state.)
*/
void EverCrypt_Hash_Incremental_finish(EverCrypt_Hash_Incremental_hash_state *s, uint8_t *dst);
void
EverCrypt_Hash_Incremental_digest(EverCrypt_Hash_Incremental_state_t *state, uint8_t *output);

/**
Free a state previously allocated with `create_in`.
*/
void EverCrypt_Hash_Incremental_free(EverCrypt_Hash_Incremental_hash_state *s);
void EverCrypt_Hash_Incremental_free(EverCrypt_Hash_Incremental_state_t *state);

/**
Hash `input`, of len `len`, into `dst`, an array whose length is determined by
Hash `input`, of len `input_len`, into `output`, an array whose length is determined by
your choice of algorithm `a` (see Hacl_Spec.h). You can use the macros defined
earlier in this file to allocate a destination buffer of the right length. This
API will automatically pick the most efficient implementation, provided you have
Expand All @@ -116,34 +118,34 @@ called EverCrypt_AutoConfig2_init() before.
void
EverCrypt_Hash_Incremental_hash(
Spec_Hash_Definitions_hash_alg a,
uint8_t *dst,
uint8_t *output,
uint8_t *input,
uint32_t len
uint32_t input_len
);

#define MD5_HASH_LEN ((uint32_t)16U)
#define MD5_HASH_LEN (16U)

#define SHA1_HASH_LEN ((uint32_t)20U)
#define SHA1_HASH_LEN (20U)

#define SHA2_224_HASH_LEN ((uint32_t)28U)
#define SHA2_224_HASH_LEN (28U)

#define SHA2_256_HASH_LEN ((uint32_t)32U)
#define SHA2_256_HASH_LEN (32U)

#define SHA2_384_HASH_LEN ((uint32_t)48U)
#define SHA2_384_HASH_LEN (48U)

#define SHA2_512_HASH_LEN ((uint32_t)64U)
#define SHA2_512_HASH_LEN (64U)

#define SHA3_224_HASH_LEN ((uint32_t)28U)
#define SHA3_224_HASH_LEN (28U)

#define SHA3_256_HASH_LEN ((uint32_t)32U)
#define SHA3_256_HASH_LEN (32U)

#define SHA3_384_HASH_LEN ((uint32_t)48U)
#define SHA3_384_HASH_LEN (48U)

#define SHA3_512_HASH_LEN ((uint32_t)64U)
#define SHA3_512_HASH_LEN (64U)

#define BLAKE2S_HASH_LEN ((uint32_t)32U)
#define BLAKE2S_HASH_LEN (32U)

#define BLAKE2B_HASH_LEN ((uint32_t)64U)
#define BLAKE2B_HASH_LEN (64U)

#if defined(__cplusplus)
}
Expand Down
8 changes: 4 additions & 4 deletions include/EverCrypt_Poly1305.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ extern "C" {
#include "krml/lowstar_endianness.h"
#include "krml/internal/target.h"

#include "Hacl_Poly1305_32.h"
#include "Hacl_Poly1305_256.h"
#include "Hacl_Poly1305_128.h"
#include "Hacl_MAC_Poly1305_Simd256.h"
#include "Hacl_MAC_Poly1305_Simd128.h"
#include "Hacl_MAC_Poly1305.h"
#include "EverCrypt_AutoConfig2.h"

void EverCrypt_Poly1305_poly1305(uint8_t *dst, uint8_t *src, uint32_t len, uint8_t *key);
void EverCrypt_Poly1305_mac(uint8_t *output, uint8_t *input, uint32_t input_len, uint8_t *key);

#if defined(__cplusplus)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
*/


#ifndef __Hacl_Chacha20Poly1305_32_H
#define __Hacl_Chacha20Poly1305_32_H
#ifndef __Hacl_AEAD_Chacha20Poly1305_H
#define __Hacl_AEAD_Chacha20Poly1305_H

#if defined(__cplusplus)
extern "C" {
Expand All @@ -35,35 +35,33 @@ extern "C" {
#include "krml/lowstar_endianness.h"
#include "krml/internal/target.h"

#include "Hacl_Poly1305_32.h"
#include "Hacl_Chacha20.h"

/**
Encrypt a message `m` with key `k`.
The arguments `k`, `n`, `aadlen`, and `aad` are same in encryption/decryption.
Note: Encryption and decryption can be executed in-place, i.e., `m` and `cipher` can point to the same memory.
@param k Pointer to 32 bytes of memory where the AEAD key is read from.
@param n Pointer to 12 bytes of memory where the AEAD nonce is read from.
@param aadlen Length of the associated data.
@param aad Pointer to `aadlen` bytes of memory where the associated data is read from.
@param mlen Length of the message.
@param m Pointer to `mlen` bytes of memory where the message is read from.
@param cipher Pointer to `mlen` bytes of memory where the ciphertext is written to.
@param mac Pointer to 16 bytes of memory where the mac is written to.
Encrypt a message `input` with key `key`.
The arguments `key`, `nonce`, `data`, and `data_len` are same in encryption/decryption.
Note: Encryption and decryption can be executed in-place, i.e., `input` and `output` can point to the same memory.
@param output Pointer to `input_len` bytes of memory where the ciphertext is written to.
@param tag Pointer to 16 bytes of memory where the mac is written to.
@param input Pointer to `input_len` bytes of memory where the message is read from.
@param input_len Length of the message.
@param data Pointer to `data_len` bytes of memory where the associated data is read from.
@param data_len Length of the associated data.
@param key Pointer to 32 bytes of memory where the AEAD key is read from.
@param nonce Pointer to 12 bytes of memory where the AEAD nonce is read from.
*/
void
Hacl_Chacha20Poly1305_32_aead_encrypt(
uint8_t *k,
uint8_t *n,
uint32_t aadlen,
uint8_t *aad,
uint32_t mlen,
uint8_t *m,
uint8_t *cipher,
uint8_t *mac
Hacl_AEAD_Chacha20Poly1305_encrypt(
uint8_t *output,
uint8_t *tag,
uint8_t *input,
uint32_t input_len,
uint8_t *data,
uint32_t data_len,
uint8_t *key,
uint8_t *nonce
);

/**
Expand All @@ -88,20 +86,20 @@ If decryption fails, the array `m` remains unchanged and the function returns th
@returns 0 on succeess; 1 on failure.
*/
uint32_t
Hacl_Chacha20Poly1305_32_aead_decrypt(
uint8_t *k,
uint8_t *n,
uint32_t aadlen,
uint8_t *aad,
uint32_t mlen,
uint8_t *m,
uint8_t *cipher,
uint8_t *mac
Hacl_AEAD_Chacha20Poly1305_decrypt(
uint8_t *output,
uint8_t *input,
uint32_t input_len,
uint8_t *data,
uint32_t data_len,
uint8_t *key,
uint8_t *nonce,
uint8_t *tag
);

#if defined(__cplusplus)
}
#endif

#define __Hacl_Chacha20Poly1305_32_H_DEFINED
#define __Hacl_AEAD_Chacha20Poly1305_H_DEFINED
#endif
104 changes: 104 additions & 0 deletions include/Hacl_AEAD_Chacha20Poly1305_Simd128.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/* MIT License
*
* Copyright (c) 2016-2022 INRIA, CMU and Microsoft Corporation
* Copyright (c) 2022-2023 HACL* Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/


#ifndef __Hacl_AEAD_Chacha20Poly1305_Simd128_H
#define __Hacl_AEAD_Chacha20Poly1305_Simd128_H

#if defined(__cplusplus)
extern "C" {
#endif

#include <string.h>
#include "krml/internal/types.h"
#include "krml/lowstar_endianness.h"
#include "krml/internal/target.h"

#include "Hacl_Chacha20_Vec128.h"

/**
Encrypt a message `input` with key `key`.
The arguments `key`, `nonce`, `data`, and `data_len` are same in encryption/decryption.
Note: Encryption and decryption can be executed in-place, i.e., `input` and `output` can point to the same memory.
@param output Pointer to `input_len` bytes of memory where the ciphertext is written to.
@param tag Pointer to 16 bytes of memory where the mac is written to.
@param input Pointer to `input_len` bytes of memory where the message is read from.
@param input_len Length of the message.
@param data Pointer to `data_len` bytes of memory where the associated data is read from.
@param data_len Length of the associated data.
@param key Pointer to 32 bytes of memory where the AEAD key is read from.
@param nonce Pointer to 12 bytes of memory where the AEAD nonce is read from.
*/
void
Hacl_AEAD_Chacha20Poly1305_Simd128_encrypt(
uint8_t *output,
uint8_t *tag,
uint8_t *input,
uint32_t input_len,
uint8_t *data,
uint32_t data_len,
uint8_t *key,
uint8_t *nonce
);

/**
Decrypt a ciphertext `input` with key `key`.
The arguments `key`, `nonce`, `data`, and `data_len` are same in encryption/decryption.
Note: Encryption and decryption can be executed in-place, i.e., `input` and `output` can point to the same memory.
If decryption succeeds, the resulting plaintext is stored in `output` and the function returns the success code 0.
If decryption fails, the array `output` remains unchanged and the function returns the error code 1.
@param output Pointer to `input_len` bytes of memory where the message is written to.
@param input Pointer to `input_len` bytes of memory where the ciphertext is read from.
@param input_len Length of the ciphertext.
@param data Pointer to `data_len` bytes of memory where the associated data is read from.
@param data_len Length of the associated data.
@param key Pointer to 32 bytes of memory where the AEAD key is read from.
@param nonce Pointer to 12 bytes of memory where the AEAD nonce is read from.
@param tag Pointer to 16 bytes of memory where the mac is read from.
@returns 0 on succeess; 1 on failure.
*/
uint32_t
Hacl_AEAD_Chacha20Poly1305_Simd128_decrypt(
uint8_t *output,
uint8_t *input,
uint32_t input_len,
uint8_t *data,
uint32_t data_len,
uint8_t *key,
uint8_t *nonce,
uint8_t *tag
);

#if defined(__cplusplus)
}
#endif

#define __Hacl_AEAD_Chacha20Poly1305_Simd128_H_DEFINED
#endif
Loading

0 comments on commit a9e8cc2

Please sign in to comment.