Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / net / android / legacy_openssl.h
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef NET_ANDROID_LEGACY_OPENSSL_H
6 #define NET_ANDROID_LEGACY_OPENSSL_H
7
8 // This file contains a replica of the Android system OpenSSL ABI shipped in
9 // Android 4.1.x (API level 16). The ABI may not necessarily be compatible with
10 // the copy of OpenSSL shipped in Chromium. This is used to implement
11 // RSA_private_encrypt in one of the legacy client auth codepaths.
12 //
13 // See https://android.googlesource.com/platform/external/openssl/+/android-4.1.2_r2.1
14
15 namespace net {
16 namespace android {
17
18 enum {
19   ANDROID_EVP_PKEY_RSA = 6,
20 };
21
22 enum {
23   ANDROID_RSA_PKCS1_PADDING = 1,
24   ANDROID_RSA_SSLV23_PADDING = 2,
25   ANDROID_RSA_NO_PADDING = 3,
26   ANDROID_RSA_PKCS1_OAEP_PADDING = 4,
27   ANDROID_X931_PADDING = 5,
28   ANDROID_PKCS1_PSS_PADDING = 6,
29 };
30
31 struct AndroidEVP_PKEY_ASN1_METHOD;
32 struct AndroidRSA_METHOD;
33 struct AndroidSTACK;
34
35 struct AndroidCRYPTO_EX_DATA {
36   AndroidSTACK* sk;
37   int dummy;
38 };
39
40 struct AndroidENGINE {
41   const char* id;
42   // Remaining fields intentionally omitted.
43 };
44
45 struct AndroidRSA {
46   int pad;
47   long version;
48   const AndroidRSA_METHOD* meth;
49   AndroidENGINE* engine;
50   // Remaining fields intentionally omitted.
51 };
52
53 struct AndroidRSA_METHOD {
54   const char* name;
55   int (*rsa_pub_enc)(int flen,
56                      const unsigned char* from,
57                      unsigned char* to,
58                      AndroidRSA* rsa,
59                      int padding);
60   int (*rsa_pub_dec)(int flen,
61                      const unsigned char* from,
62                      unsigned char* to,
63                      AndroidRSA* rsa,
64                      int padding);
65   int (*rsa_priv_enc)(int flen,
66                       const unsigned char* from,
67                       unsigned char* to,
68                       AndroidRSA* rsa,
69                       int padding);
70   int (*rsa_priv_dec)(int flen,
71                       const unsigned char* from,
72                       unsigned char* to,
73                       AndroidRSA* rsa,
74                       int padding);
75   // Remaining fields intentionally omitted.
76 };
77
78 struct AndroidEVP_PKEY {
79   int type;
80   int save_type;
81   // Note: this value must NOT be modified using Chromium's CRYPTO_add
82   // function. That may not necessarily use the same locking implementation as
83   // system OpenSSL.
84   int references;
85   const AndroidEVP_PKEY_ASN1_METHOD* ameth;
86   AndroidENGINE* engine;
87   union {
88     char* ptr;
89     AndroidRSA* rsa;
90   } pkey;
91   int save_parameters;
92   AndroidSTACK* attributes;
93 };
94
95 }  // namespace android
96 }  // namespace net
97
98 #endif  // NET_ANDROID_LEGACY_OPENSSL_H