Debian Codegraph @

crt/s2n/tests/testlib/s2n_resumption_testlib.c

raw symbols SCIP
1 /*
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License").
5 * You may not use this file except in compliance with the License.
6 * A copy of the License is located at
7 *
8 * http://aws.amazon.com/apache2.0
9 *
10 * or in the "license" file accompanying this file. This file is distributed
11 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12 * express or implied. See the License for the specific language governing
13 * permissions and limitations under the License.
14 */
15 #include "testlib/s2n_testlib.h"
16
17 S2N_RESULT s2n_resumption_test_ticket_key_setup(struct s2n_config *config)
18 {
19 /**
20 *= https://www.rfc-editor.org/rfc/rfc5869#appendix-A.1
21 *# PRK = 0x077709362c2e32df0ddc3f0dc47bba63
22 *# 90b6c73bb50f9c3122ec844ad7c2b3e5 (32 octets)
23 **/
24 S2N_CHECKED_BLOB_FROM_HEX(ticket_key, RESULT_GUARD,
25 "077709362c2e32df0ddc3f0dc47bba63"
26 "90b6c73bb50f9c3122ec844ad7c2b3e5");
27
28 /* Set up encryption key */
29 uint64_t current_time = 0;
30 uint8_t ticket_key_name[16] = "2016.07.26.15\0";
31
32 RESULT_GUARD_POSIX(s2n_config_set_session_tickets_onoff(config, true));
33 RESULT_GUARD_POSIX(config->wall_clock(config->sys_clock_ctx, &current_time));
34 RESULT_GUARD_POSIX(s2n_config_add_ticket_crypto_key(config, ticket_key_name, strlen((char *) ticket_key_name),
35 ticket_key.data, ticket_key.size, current_time / ONE_SEC_IN_NANOS));
36 return S2N_RESULT_OK;
37 }