Debian Codegraph @

crt/s2n/bin/policy.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
16 #include <stdint.h>
17 #include <stdlib.h>
18 #include <unistd.h>
19
20 #include "api/s2n.h"
21 #include "tls/policy/s2n_policy_feature.h"
22 #include "tls/s2n_security_policies.h"
23
24 static int usage()
25 {
26 printf("policy <version>\n"
27 "example: policy default_tls13\n\n");
28 return 0;
29 }
30
31 int main(int argc, char *const *argv)
32 {
33 if (argc != 2) {
34 usage();
35 exit(1);
36 }
37
38 if (s2n_init() != S2N_SUCCESS) {
39 fprintf(stderr, "Error: Failed to initialize s2n\n");
40 exit(1);
41 }
42
43 const char *policy_name = argv[1];
44 const struct s2n_security_policy *policy = NULL;
45 if (s2n_find_security_policy_from_version(policy_name, &policy) != S2N_SUCCESS) {
46 fprintf(stderr, "Error: Failed to find security policy\n");
47 s2n_cleanup();
48 exit(1);
49 }
50
51 uint32_t output_size = 0;
52 if (s2n_security_policy_write_fd(policy, S2N_POLICY_FORMAT_DEBUG_V1, STDOUT_FILENO, &output_size) != S2N_SUCCESS) {
53 s2n_cleanup();
54 exit(1);
55 }
56
57 s2n_cleanup();
58 return 0;
59 }