Skip to content

Commit

Permalink
Adding HPKE support for crypto operations per RFC-9180
Browse files Browse the repository at this point in the history
Supported cryptographic schemes:
KEM (key encapsulation mechanism)
- 0x0020: DHKEM(X25519, HKDF-SHA256)

KDF (key derivation function)
- 0x0001: HKDF-SHA256

AEAD (Authenticated Encryption with Associated Data)
- 0x0001: AES-128-GCM
- 0x0002: AES-256-GCM
- 0x0003: ChaCha20Poly1305
  • Loading branch information
Jorge Saldivar committed Jun 9, 2023
1 parent 2f785af commit 85a2056
Show file tree
Hide file tree
Showing 20 changed files with 2,908 additions and 7 deletions.
5 changes: 5 additions & 0 deletions common/src/jni/main/cpp/conscrypt/jniutil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ JavaVM *gJavaVM;
jclass cryptoUpcallsClass;
jclass openSslInputStreamClass;
jclass nativeRefClass;
jclass nativeRefHpkeCtxClass;

jclass byteArrayClass;
jclass calendarClass;
Expand Down Expand Up @@ -57,6 +58,7 @@ jmethodID buffer_isDirectMethod;
jmethodID cryptoUpcallsClass_rawSignMethod;
jmethodID cryptoUpcallsClass_rsaSignMethod;
jmethodID cryptoUpcallsClass_rsaDecryptMethod;
jmethodID nativeRefHpkeCtxClass_constructor;
jmethodID sslHandshakeCallbacks_verifyCertificateChain;
jmethodID sslHandshakeCallbacks_onSSLStateChange;
jmethodID sslHandshakeCallbacks_clientCertificateRequested;
Expand Down Expand Up @@ -86,6 +88,8 @@ void init(JavaVM* vm, JNIEnv* env) {
env, TO_STRING(JNI_JARJAR_PREFIX) "org/conscrypt/CryptoUpcalls");
nativeRefClass = getGlobalRefToClass(
env, TO_STRING(JNI_JARJAR_PREFIX) "org/conscrypt/NativeRef");
nativeRefHpkeCtxClass = getGlobalRefToClass(
env, TO_STRING(JNI_JARJAR_PREFIX) "org/conscrypt/NativeRef$EVP_HPKE_CTX");
openSslInputStreamClass = getGlobalRefToClass(
env, TO_STRING(JNI_JARJAR_PREFIX) "org/conscrypt/OpenSSLBIOInputStream");
sslHandshakeCallbacksClass = getGlobalRefToClass(
Expand Down Expand Up @@ -145,6 +149,7 @@ void init(JavaVM* vm, JNIEnv* env) {
if (cryptoUpcallsClass_rsaDecryptMethod == nullptr) {
env->FatalError("Could not find rsaDecryptWithPrivateKey");
}
nativeRefHpkeCtxClass_constructor = env->GetMethodID(nativeRefHpkeCtxClass, "<init>", "(J)V");
}

void jniRegisterNativeMethods(JNIEnv* env, const char* className, const JNINativeMethod* gMethods,
Expand Down
Loading

0 comments on commit 85a2056

Please sign in to comment.