mirror of
https://github.com/corda/corda.git
synced 2024-12-28 16:58:55 +00:00
Register Kryo serializer for use inside the SGX enclave. (#23)
This commit is contained in:
parent
aa82c55c87
commit
3ae53683ea
@ -46,6 +46,7 @@ clean:
|
|||||||
$(MAKE) -C linux-sgx clean
|
$(MAKE) -C linux-sgx clean
|
||||||
$(MAKE) -C linux-sgx-driver clean
|
$(MAKE) -C linux-sgx-driver clean
|
||||||
[ ! -d jdk8u ] || $(MAKE) -C jdk8u clean
|
[ ! -d jdk8u ] || $(MAKE) -C jdk8u clean
|
||||||
|
../gradlew -p .. verify-enclave:clean
|
||||||
$(MAKE) -C avian clean
|
$(MAKE) -C avian clean
|
||||||
|
|
||||||
.PHONY: distclean
|
.PHONY: distclean
|
||||||
|
@ -53,6 +53,8 @@ void check_transaction(void *reqbuf, size_t buflen, char *error) {
|
|||||||
JNI_CreateJavaVM(&vm, &env_void, &vmArgs);
|
JNI_CreateJavaVM(&vm, &env_void, &vmArgs);
|
||||||
JNIEnv* env = static_cast<JNIEnv*>(env_void);
|
JNIEnv* env = static_cast<JNIEnv*>(env_void);
|
||||||
|
|
||||||
|
env->FindClass("com/r3/enclaves/txverify/KryoVerifierSerializationScheme");
|
||||||
|
if (!env->ExceptionCheck()) {
|
||||||
jclass c = env->FindClass("com/r3/enclaves/txverify/Enclavelet");
|
jclass c = env->FindClass("com/r3/enclaves/txverify/Enclavelet");
|
||||||
if (!env->ExceptionCheck()) {
|
if (!env->ExceptionCheck()) {
|
||||||
jmethodID m = env->GetStaticMethodID(c, "verifyInEnclave", "([B)V");
|
jmethodID m = env->GetStaticMethodID(c, "verifyInEnclave", "([B)V");
|
||||||
@ -62,6 +64,7 @@ void check_transaction(void *reqbuf, size_t buflen, char *error) {
|
|||||||
jobject result = env->CallStaticObjectMethod(c, m, reqbits);
|
jobject result = env->CallStaticObjectMethod(c, m, reqbits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (env->ExceptionCheck()) {
|
if (env->ExceptionCheck()) {
|
||||||
jthrowable exception = env->ExceptionOccurred();
|
jthrowable exception = env->ExceptionOccurred();
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
package com.r3.enclaves.txverify
|
||||||
|
|
||||||
|
import net.corda.core.serialization.SerializationContext
|
||||||
|
import net.corda.core.serialization.SerializationDefaults
|
||||||
|
import net.corda.core.utilities.ByteSequence
|
||||||
|
import net.corda.nodeapi.internal.serialization.AbstractKryoSerializationScheme
|
||||||
|
import net.corda.nodeapi.internal.serialization.KRYO_P2P_CONTEXT
|
||||||
|
import net.corda.nodeapi.internal.serialization.KryoHeaderV0_1
|
||||||
|
import net.corda.nodeapi.internal.serialization.SerializationFactoryImpl
|
||||||
|
|
||||||
|
@Suppress("UNUSED")
|
||||||
|
private class KryoVerifierSerializationScheme : AbstractKryoSerializationScheme() {
|
||||||
|
override fun canDeserializeVersion(byteSequence: ByteSequence, target: SerializationContext.UseCase): Boolean {
|
||||||
|
return byteSequence == KryoHeaderV0_1 && target == SerializationContext.UseCase.P2P
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun rpcClientKryoPool(context: SerializationContext) = throw UnsupportedOperationException()
|
||||||
|
override fun rpcServerKryoPool(context: SerializationContext) = throw UnsupportedOperationException()
|
||||||
|
|
||||||
|
private companion object {
|
||||||
|
init {
|
||||||
|
SerializationDefaults.SERIALIZATION_FACTORY = SerializationFactoryImpl().apply {
|
||||||
|
registerScheme(KryoVerifierSerializationScheme())
|
||||||
|
}
|
||||||
|
SerializationDefaults.P2P_CONTEXT = KRYO_P2P_CONTEXT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user