aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/restricted/aws/s2n/tls/s2n_handshake_hashes.h
blob: 22d157deb4609f57235df00a50685281bd54f865 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */

#pragma once

#include "api/s2n.h"

#include "crypto/s2n_hash.h"
#include "crypto/s2n_tls13_keys.h"

struct s2n_handshake_hashes {
    struct s2n_hash_state md5;
    struct s2n_hash_state sha1;
    struct s2n_hash_state sha224;
    struct s2n_hash_state sha256;
    struct s2n_hash_state sha384;
    struct s2n_hash_state sha512;
    struct s2n_hash_state md5_sha1;

    /* TLS1.3 requires transcript hash digests to calculate secrets.
     */
    uint8_t transcript_hash_digest[S2N_TLS13_SECRET_MAX_LEN];

    /* To avoid allocating memory for hash objects, we reuse one temporary hash object.
     * Do NOT rely on this hash state maintaining its value outside of the current context.
     */
    struct s2n_hash_state hash_workspace;
};

S2N_RESULT s2n_handshake_hashes_new(struct s2n_handshake_hashes **hashes);
S2N_RESULT s2n_handshake_hashes_wipe(struct s2n_handshake_hashes *hashes);
S2N_CLEANUP_RESULT s2n_handshake_hashes_free(struct s2n_handshake_hashes **hashes);