| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
#include <stdint.h> |
| 17 |
|
| 18 |
#include "crypto/s2n_hmac.h" |
| 19 |
|
| 20 |
#include "tls/s2n_record.h" |
| 21 |
#include "tls/s2n_prf.h" |
| 22 |
#include "tls/s2n_connection.h" |
| 23 |
|
| 24 |
#include <smack.h> |
| 25 |
#include <smack-contracts.h> |
| 26 |
#include "ct-verif.h" |
| 27 |
#include "sidetrail.h" |
| 28 |
|
| 29 |
int simple_cbc_wrapper(int currently_in_hash_block, int size, int *xor_pad, int * digest_pad) |
| 30 |
{ |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
__VERIFIER_ASSERT_MAX_LEAKAGE(68); |
| 38 |
|
| 39 |
public_in(__SMACK_value(currently_in_hash_block)); |
| 40 |
__VERIFIER_assume(currently_in_hash_block >= 0); |
| 41 |
__VERIFIER_assume(currently_in_hash_block < BLOCK_SIZE); |
| 42 |
|
| 43 |
struct s2n_hmac_state hmac = { |
| 44 |
.alg = S2N_HMAC_SHA1, |
| 45 |
.hash_block_size = BLOCK_SIZE, |
| 46 |
.currently_in_hash_block = 0, |
| 47 |
.digest_size = SHA_DIGEST_LENGTH, |
| 48 |
.xor_pad_size = BLOCK_SIZE, |
| 49 |
.inner.alg = S2N_HASH_SHA1, |
| 50 |
.inner.currently_in_hash_block = 0, |
| 51 |
.inner_just_key.alg = S2N_HASH_SHA1, |
| 52 |
.inner_just_key.currently_in_hash_block = 0, |
| 53 |
.outer.alg = S2N_HASH_SHA1, |
| 54 |
.outer.currently_in_hash_block = 0, |
| 55 |
.outer_just_key.alg = S2N_HASH_SHA1, |
| 56 |
.outer_just_key.currently_in_hash_block = 0, |
| 57 |
.xor_pad = *xor_pad, |
| 58 |
|
| 59 |
.digest_pad = *digest_pad |
| 60 |
}; |
| 61 |
|
| 62 |
|
| 63 |
struct s2n_crypto_parameters client; |
| 64 |
struct s2n_connection conn = { |
| 65 |
.client = &client, |
| 66 |
.mode = S2N_SERVER, |
| 67 |
.extension_requests_sent = { 0 }, |
| 68 |
.extension_requests_received = { 0 }, |
| 69 |
.extension_responses_received = { 0 } |
| 70 |
}; |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
int data[MAX_SIZE]; |
| 77 |
public_in(__SMACK_value(size)); |
| 78 |
__VERIFIER_assume(size >= 0); |
| 79 |
__VERIFIER_assume(size <= MAX_SIZE); |
| 80 |
|
| 81 |
struct s2n_blob decrypted = { |
| 82 |
.data = data, |
| 83 |
.size = size, |
| 84 |
.allocated = 1, |
| 85 |
}; |
| 86 |
|
| 87 |
return s2n_verify_cbc(&conn, &hmac, &decrypted); |
| 88 |
} |