1 /* Copyright (C) 2015 The Android Open Source Project
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License. */
14
15 /* This program generates output that is expected to become
16 * NativeConstants.java. This reifies several OpenSSL constants into Java. */
17
18 #include <stdio.h>
19
20 #include <openssl/ec.h>
21 #include <openssl/rsa.h>
22 #include <openssl/ssl.h>
23 #include <openssl/x509v3.h>
24 #include <openssl/evp.h>
25 #include <openssl/aead.h>
26
27 static const char kCopyright[] =
28 "/* Copyright (C) 2015 The Android Open Source Project\n"
29 " *\n"
30 " * Licensed under the Apache License, Version 2.0 (the \"License\");\n"
31 " * you may not use this file except in compliance with the License.\n"
32 " * You may obtain a copy of the License at\n"
33 " *\n"
34 " * http://www.apache.org/licenses/LICENSE-2.0\n"
35 " *\n"
36 " * Unless required by applicable law or agreed to in writing, software\n"
37 " * distributed under the License is distributed on an \"AS IS\" BASIS,\n"
38 " * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or "
39 "implied.\n"
40 " * See the License for the specific language governing permissions and\n"
41 " * limitations under the License. */\n";
42
main(int,char **)43 int main(int /* argc */, char ** /* argv */) {
44 printf("%s\n", kCopyright);
45 printf("/* This file was generated by generate_constants.cc. */\n\n");
46 printf("package org.conscrypt;\n\n");
47 printf("final class NativeConstants {\n");
48
49 #define CONST(x) \
50 printf(" static final int %s = %ld;\n", #x, (long int)(x))
51
52 CONST(EXFLAG_CA);
53 CONST(EXFLAG_CRITICAL);
54
55 CONST(EVP_PKEY_RSA);
56 CONST(EVP_PKEY_EC);
57
58 CONST(RSA_PKCS1_PADDING);
59 CONST(RSA_NO_PADDING);
60 CONST(RSA_PKCS1_OAEP_PADDING);
61 CONST(RSA_PKCS1_PSS_PADDING);
62
63 CONST(SSL_MODE_SEND_FALLBACK_SCSV);
64 CONST(SSL_MODE_CBC_RECORD_SPLITTING);
65 CONST(SSL_MODE_ENABLE_FALSE_START);
66
67 CONST(SSL_OP_CIPHER_SERVER_PREFERENCE);
68 CONST(SSL_OP_NO_TICKET);
69 CONST(SSL_OP_NO_SSLv3);
70 CONST(SSL_OP_NO_TLSv1);
71 CONST(SSL_OP_NO_TLSv1_1);
72 CONST(SSL_OP_NO_TLSv1_2);
73
74 CONST(SSL_ERROR_NONE);
75 CONST(SSL_ERROR_WANT_READ);
76 CONST(SSL_ERROR_WANT_WRITE);
77 CONST(SSL_ERROR_ZERO_RETURN);
78
79 CONST(SSL_SENT_SHUTDOWN);
80 CONST(SSL_RECEIVED_SHUTDOWN);
81
82 CONST(TLS_CT_RSA_SIGN);
83 CONST(TLS_CT_ECDSA_SIGN);
84
85 CONST(SSL_VERIFY_NONE);
86 CONST(SSL_VERIFY_PEER);
87 CONST(SSL_VERIFY_FAIL_IF_NO_PEER_CERT);
88
89 CONST(SSL_CB_HANDSHAKE_START);
90 CONST(SSL_CB_HANDSHAKE_DONE);
91
92 CONST(SSL3_RT_MAX_PLAIN_LENGTH);
93 CONST(SSL3_RT_MAX_PACKET_SIZE);
94 CONST(SSL3_RT_CHANGE_CIPHER_SPEC);
95 CONST(SSL3_RT_ALERT);
96 CONST(SSL3_RT_HANDSHAKE);
97 CONST(SSL3_RT_APPLICATION_DATA);
98 CONST(SSL3_RT_HEADER_LENGTH);
99 #undef CONST
100
101 printf("}\n");
102
103 return 0;
104 }
105