1 /*
2  * Copyright (C) 2022 The Android Open Source Project
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  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #include <jni.h>
17 
18 /* Header for class HpkeJni */
19 #ifndef ADSERVICES_SERVICE_CORE_JNI_INCLUDE_OHTTP_JNI_H_
20 #define ADSERVICES_SERVICE_CORE_JNI_INCLUDE_OHTTP_JNI_H_
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 /*
25  * Class:     OhttpJniWrapper
26  * Method:    hpkeKemDhkemX25519HkdfSha256
27  * Signature: ()J
28  */
29 JNIEXPORT jlong JNICALL
30 Java_com_android_adservices_ohttp_OhttpJniWrapper_hpkeKemDhkemX25519HkdfSha256(
31     JNIEnv *, jclass);
32 /*
33  * Class:     OhttpJniWrapper
34  * Method:    hpkeKdfHkdfSha256
35  * Signature: ()J
36  */
37 JNIEXPORT jlong JNICALL
38 Java_com_android_adservices_ohttp_OhttpJniWrapper_hpkeKdfHkdfSha256(JNIEnv *,
39                                                                     jclass);
40 
41 /*
42  * Class:     OhttpJniWrapper
43  * Method:    hpkeAeadAes128Gcm
44  * Signature: ()J
45  */
46 JNIEXPORT jlong JNICALL
47 Java_com_android_adservices_ohttp_OhttpJniWrapper_hpkeAeadAes128Gcm(JNIEnv *,
48                                                                     jclass);
49 
50 /*
51  * Class:     OhttpJniWrapper
52  * Method:    hpkeAeadAes256Gcm
53  * Signature: ()J
54  */
55 JNIEXPORT jlong JNICALL
56 Java_com_android_adservices_ohttp_OhttpJniWrapper_hpkeAeadAes256Gcm(JNIEnv *,
57                                                                     jclass);
58 
59 /*
60  * Class:     OhttpJniWrapper
61  * Method:    hkdfSha256MessageDigest
62  * Signature: ()J
63  */
64 JNIEXPORT jlong JNICALL
65 Java_com_android_adservices_ohttp_OhttpJniWrapper_hkdfSha256MessageDigest(
66     JNIEnv *env, jclass);
67 
68 /*
69  * Class:     OhttpJniWrapper
70  * Method:    hpkeCtxFree
71  * Signature: (J)
72  */
73 JNIEXPORT void JNICALL
74 Java_com_android_adservices_ohttp_OhttpJniWrapper_hpkeCtxFree(JNIEnv *env,
75                                                               jclass,
76                                                               jlong hpkeCtxRef);
77 
78 /*
79  * Class:     OhttpJniWrapper
80  * Method:    hpkeCtxNew
81  * Signature: ()J
82  */
83 JNIEXPORT jlong JNICALL
84 Java_com_android_adservices_ohttp_OhttpJniWrapper_hpkeCtxNew(JNIEnv *env,
85                                                              jclass);
86 
87 /*
88  * Class:     OhttpJniWrapper
89  * Method:    hpkeCtxSetupSenderWithSeed
90  * Signature: (JJJJ[B[B[B)[B
91  */
92 JNIEXPORT jbyteArray JNICALL
93 Java_com_android_adservices_ohttp_OhttpJniWrapper_hpkeCtxSetupSenderWithSeed(
94     JNIEnv *env, jclass, jlong senderHpkeCtxRef, jlong evpKemRef,
95     jlong evpKdfRef, jlong evpAeadRef, jbyteArray publicKeyArray,
96     jbyteArray infoArray, jbyteArray seedArray);
97 
98 /*
99  * Class:     OhttpJniWrapper
100  * Method:    hpkeSetupRecipient
101  * Signature: (JJJJ[B[B[B)Z
102  */
103 JNIEXPORT jboolean JNICALL
104 Java_com_android_adservices_ohttp_OhttpJniWrapper_hpkeSetupRecipient(
105     JNIEnv *env, jclass,
106     jlong hpkeCtxRef,
107     jlong evpKemRef,
108     jlong evpKdfRef,
109     jlong evpAeadRef,
110     jbyteArray privKeyArray,
111     jbyteArray encArray,
112     jbyteArray infoArray);
113 
114 /*
115  * Class:     OhttpJniWrapper
116  * Method:    gatewayDecrypt
117  * Signature: (JJJJ[B)[B
118  */
119 JNIEXPORT jbyteArray JNICALL
120 Java_com_android_adservices_ohttp_OhttpJniWrapper_gatewayDecrypt(
121     JNIEnv *env, jclass,
122     jlong hpkeCtxRef,
123     jlong evpKemRef,
124     jlong evpKdfRef,
125     jlong evpAeadRef,
126     jbyteArray encryptedDataArray);
127 
128 /*
129  * Class:     OhttpJniWrapper
130  * Method:    hpkeCtxSeal
131  * Signature: (J[B[B)[B
132  */
133 JNIEXPORT jbyteArray JNICALL
134 Java_com_android_adservices_ohttp_OhttpJniWrapper_hpkeCtxSeal(
135     JNIEnv *env, jclass, jlong senderHpkeCtxRef, jbyteArray plaintextArray,
136     jbyteArray aadArray);
137 
138 /*
139  * Class:     OhttpJniWrapper
140  * Method:    hpkeExport
141  * Signature: (J[BI)[B
142  */
143 JNIEXPORT jbyteArray JNICALL
144 Java_com_android_adservices_ohttp_OhttpJniWrapper_hpkeExport(JNIEnv* env, jclass, jlong hpkeCtxRef,
145                                                        jbyteArray exporterCtxArray, jint length);
146 /*
147  * Class:     OhttpJniWrapper
148  * Method:    hkdfExtract
149  * Signature: (J[B[B)[B
150  */
151 JNIEXPORT jbyteArray JNICALL
152 Java_com_android_adservices_ohttp_OhttpJniWrapper_hkdfExtract(
153     JNIEnv *env, jclass, jlong hkdfMd, jbyteArray secret, jbyteArray salt);
154 
155 /*
156  * Class:     OhttpJniWrapper
157  * Method:    hkdfExpand
158  * Signature: (J[B[BI)[B
159  */
160 JNIEXPORT jbyteArray JNICALL
161 Java_com_android_adservices_ohttp_OhttpJniWrapper_hkdfExpand(
162     JNIEnv *env, jclass, jlong hkdfMd, jbyteArray prkArray,
163     jbyteArray infoArray, jint key_len);
164 
165 /*
166  * Class:     OhttpJniWrapper
167  * Method:    aeadOpen
168  * Signature: (J[B[B[B)[B
169  */
170 JNIEXPORT jbyteArray JNICALL
171 Java_com_android_adservices_ohttp_OhttpJniWrapper_aeadOpen(
172     JNIEnv *env, jclass, jlong evpAeadRef, jbyteArray keyArray,
173     jbyteArray nonceArray, jbyteArray cipherTextArray);
174 
175 
176 /*
177  * Class:     OhttpJniWrapper
178  * Method:    aeadOpen
179  * Signature: (J[B[B[B)[B
180  */
181 JNIEXPORT jbyteArray JNICALL
182 Java_com_android_adservices_ohttp_OhttpJniWrapper_aeadSeal(
183     JNIEnv *env,
184     jclass,
185     jlong evpAeadRef,
186     jbyteArray keyArray,
187     jbyteArray nonceArray,
188     jbyteArray plainTextArray);
189 
190 #ifdef __cplusplus
191 }
192 #endif
193 #endif  // ADSERVICES_SERVICE_CORE_JNI_INCLUDE_OHTTP_JNI_H_
194