├── .asf.yaml
├── .github
└── workflows
│ └── ci.yml
├── .gitignore
├── DISCLAIMER-WIP
├── LICENSE
├── NOTICE
├── Proposal.md
├── README.md
├── archetype
├── pom.xml
└── src
│ ├── main
│ └── resources
│ │ ├── META-INF
│ │ └── maven
│ │ │ └── archetype-metadata.xml
│ │ └── archetype-resources
│ │ ├── common
│ │ └── pom.xml
│ │ ├── enclave
│ │ ├── pom.xml
│ │ └── src
│ │ │ └── main
│ │ │ └── resources
│ │ │ └── META-INF
│ │ │ └── native-image
│ │ │ ├── jni-config.json
│ │ │ ├── proxy-config.json
│ │ │ ├── reflect-config.json
│ │ │ ├── resource-config.json
│ │ │ └── serialization-config.json
│ │ ├── host
│ │ └── pom.xml
│ │ └── pom.xml
│ └── test
│ └── resources
│ └── projects
│ └── basic
│ ├── archetype.properties
│ └── goal.txt
├── benchmark
├── guomi
│ ├── common
│ │ ├── pom.xml
│ │ └── src
│ │ │ └── main
│ │ │ └── java
│ │ │ └── org
│ │ │ └── apache
│ │ │ └── teaclave
│ │ │ └── javasdk
│ │ │ └── benchmark
│ │ │ └── guomi
│ │ │ └── common
│ │ │ └── SMService.java
│ ├── enclave
│ │ ├── pom.xml
│ │ └── src
│ │ │ └── main
│ │ │ ├── java
│ │ │ └── org
│ │ │ │ └── apache
│ │ │ │ └── teaclave
│ │ │ │ └── javasdk
│ │ │ │ └── benchmark
│ │ │ │ └── guomi
│ │ │ │ └── enclave
│ │ │ │ ├── SM2ServiceImpl.java
│ │ │ │ ├── SM3ServiceImpl.java
│ │ │ │ ├── SM4ServiceImpl.java
│ │ │ │ └── SMServiceImpl.java
│ │ │ └── resources
│ │ │ ├── META-INF
│ │ │ └── native-image
│ │ │ │ ├── jni-config.json
│ │ │ │ ├── proxy-config.json
│ │ │ │ ├── reflect-config.json
│ │ │ │ ├── resource-config.json
│ │ │ │ └── serialization-config.json
│ │ │ └── java_enclave_configure.json
│ ├── host
│ │ ├── pom.xml
│ │ └── src
│ │ │ └── main
│ │ │ └── java
│ │ │ └── org
│ │ │ └── apache
│ │ │ └── teaclave
│ │ │ └── javasdk
│ │ │ └── benchmark
│ │ │ └── guomi
│ │ │ └── host
│ │ │ └── GuoMiBenchMark.java
│ ├── pom.xml
│ └── run.sh
└── string
│ ├── common
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── org
│ │ └── apache
│ │ └── teaclave
│ │ └── javasdk
│ │ └── benchmark
│ │ └── string
│ │ └── common
│ │ └── StringOperationMetric.java
│ ├── enclave
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ ├── java
│ │ └── org
│ │ │ └── apache
│ │ │ └── teaclave
│ │ │ └── javasdk
│ │ │ └── benchmark
│ │ │ └── string
│ │ │ └── enclave
│ │ │ └── StringOperationMetricImpl.java
│ │ └── resources
│ │ ├── META-INF
│ │ └── native-image
│ │ │ ├── jni-config.json
│ │ │ ├── proxy-config.json
│ │ │ ├── reflect-config.json
│ │ │ ├── resource-config.json
│ │ │ └── serialization-config.json
│ │ └── java_enclave_configure.json
│ ├── host
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── org
│ │ └── apache
│ │ └── teaclave
│ │ └── javasdk
│ │ └── benchmark
│ │ └── string
│ │ └── host
│ │ └── StringBenchMark.java
│ ├── pom.xml
│ └── run.sh
├── build.sh
├── coverage
└── run.sh
├── docs
└── resources
│ ├── JavaEnclave_Application_Dependency.png
│ ├── JavaEnclave_Architecture.png
│ ├── JavaEnclave_Project_Structure.png
│ └── SGX2_Supported_Check.png
├── licenses
├── LICENSE-bouncycastle.txt
├── LICENSE-graal.txt
└── LICENSE-sgx-sdk.txt
├── samples
├── helloworld
│ ├── common
│ │ ├── pom.xml
│ │ └── src
│ │ │ └── main
│ │ │ └── java
│ │ │ └── org
│ │ │ └── apache
│ │ │ └── teaclave
│ │ │ └── javasdk
│ │ │ └── samples
│ │ │ └── helloworld
│ │ │ └── common
│ │ │ └── Service.java
│ ├── enclave
│ │ ├── pom.xml
│ │ └── src
│ │ │ └── main
│ │ │ ├── java
│ │ │ └── org
│ │ │ │ └── apache
│ │ │ │ └── teaclave
│ │ │ │ └── samples
│ │ │ │ └── helloworld
│ │ │ │ └── enclave
│ │ │ │ └── ServiceImpl.java
│ │ │ └── resources
│ │ │ └── META-INF
│ │ │ └── native-image
│ │ │ ├── jni-config.json
│ │ │ ├── proxy-config.json
│ │ │ ├── reflect-config.json
│ │ │ ├── resource-config.json
│ │ │ └── serialization-config.json
│ ├── host
│ │ ├── pom.xml
│ │ └── src
│ │ │ └── main
│ │ │ └── java
│ │ │ └── org
│ │ │ └── apache
│ │ │ └── teaclave
│ │ │ └── javasdk
│ │ │ └── samples
│ │ │ └── helloworld
│ │ │ └── host
│ │ │ └── Main.java
│ ├── pom.xml
│ └── run.sh
└── springboot
│ ├── common
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── org
│ │ └── apache
│ │ └── teaclave
│ │ └── javasdk
│ │ └── samples
│ │ └── springboot
│ │ └── common
│ │ └── SBEnclaveService.java
│ ├── enclave
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ ├── java
│ │ └── org
│ │ │ └── apache
│ │ │ └── teaclave
│ │ │ └── javasdk
│ │ │ └── samples
│ │ │ └── springboot
│ │ │ └── enclave
│ │ │ └── EnclaveServiceImpl.java
│ │ └── resources
│ │ └── META-INF
│ │ └── native-image
│ │ ├── jni-config.json
│ │ ├── proxy-config.json
│ │ ├── reflect-config.json
│ │ ├── resource-config.json
│ │ └── serialization-config.json
│ ├── host
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── org
│ │ └── apache
│ │ └── teaclave
│ │ └── javasdk
│ │ └── samples
│ │ └── springboot
│ │ └── host
│ │ ├── Application.java
│ │ ├── EnclaveDigestController.java
│ │ └── EnclaveEncDecController.java
│ ├── pom.xml
│ └── run.sh
├── sdk
├── common
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── org
│ │ └── apache
│ │ └── teaclave
│ │ └── javasdk
│ │ └── common
│ │ ├── EmbeddedLibOSInnerAttestationReport.java
│ │ ├── EnclaveInvocationContext.java
│ │ ├── EnclaveInvocationResult.java
│ │ ├── SerializationHelper.java
│ │ ├── ServiceHandler.java
│ │ ├── SocketEnclaveInvocationContext.java
│ │ ├── annotations
│ │ ├── EnclaveMethod.java
│ │ └── EnclaveService.java
│ │ └── exception
│ │ └── ConfidentialComputingException.java
├── enclave
│ ├── docs
│ │ └── Incompatibilities.md
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── org
│ │ │ │ └── apache
│ │ │ │ └── teaclave
│ │ │ │ └── javasdk
│ │ │ │ └── enclave
│ │ │ │ ├── EnclaveEntry.java
│ │ │ │ ├── EnclaveFeature.java
│ │ │ │ ├── EnclaveOptions.java
│ │ │ │ ├── EnclavePlatFormSettings.java
│ │ │ │ ├── EnclavePrologue.java
│ │ │ │ ├── EnclaveRandomFeature.java
│ │ │ │ ├── InvocationWrapper.java
│ │ │ │ ├── NativeCommandUtil.java
│ │ │ │ ├── agent
│ │ │ │ ├── EnclaveAgent.java
│ │ │ │ ├── EnclaveAgentServiceImpl.java
│ │ │ │ ├── EnclaveShutDown.java
│ │ │ │ └── RemoteAttestation.java
│ │ │ │ ├── c
│ │ │ │ └── EnclaveEnvironment.java
│ │ │ │ ├── cpufeatures
│ │ │ │ ├── EnclaveAMD64CPUFeatureAccess.java
│ │ │ │ └── EnclaveAMD64CPUFeatureAccessFeature.java
│ │ │ │ ├── framework
│ │ │ │ ├── EnclaveContext.java
│ │ │ │ ├── EnclaveMethodInvoker.java
│ │ │ │ ├── LoadServiceInvoker.java
│ │ │ │ ├── ServiceMethodInvoker.java
│ │ │ │ └── UnloadServiceInvoker.java
│ │ │ │ ├── substitutes
│ │ │ │ └── NativePRNGSubstitutions.java
│ │ │ │ └── system
│ │ │ │ ├── EnclaveMemoryFeature.java
│ │ │ │ ├── EnclaveMuslLibcFeature.java
│ │ │ │ ├── EnclavePhysicalMemory.java
│ │ │ │ └── EnclaveVirtualMemoryProvider.java
│ │ ├── native
│ │ │ └── cpp
│ │ │ │ └── platform
│ │ │ │ ├── libos_occlum_enclave
│ │ │ │ └── remote_attestation_generate
│ │ │ │ │ ├── Makefile
│ │ │ │ │ ├── jni_occlum_attestation_generate.c
│ │ │ │ │ └── jni_occlum_attestation_generate.h
│ │ │ │ └── tee_sdk_svm
│ │ │ │ ├── edge_routines
│ │ │ │ ├── Makefile
│ │ │ │ ├── sgx_mmap.c
│ │ │ │ ├── sgx_mmap.h
│ │ │ │ ├── tee_sdk_symbol.c
│ │ │ │ └── tee_sdk_symbol.h
│ │ │ │ ├── remote_attestation_generate
│ │ │ │ ├── Makefile
│ │ │ │ ├── generate_attestation_report.c
│ │ │ │ └── generate_attestation_report.h
│ │ │ │ └── wrapper
│ │ │ │ ├── Makefile
│ │ │ │ ├── tee_sdk_wrapper.c
│ │ │ │ └── tee_sdk_wrapper.h
│ │ └── resources
│ │ │ ├── META-INF
│ │ │ ├── native-image
│ │ │ │ ├── org.apache.teaclave.javasdk
│ │ │ │ │ └── enclave
│ │ │ │ │ │ └── native-image.properties
│ │ │ │ ├── reflect-config.json
│ │ │ │ └── serialization-config.json
│ │ │ └── services
│ │ │ │ └── org.graalvm.compiler.options.OptionDescriptors
│ │ │ └── native
│ │ │ └── enc_environment.h
│ │ └── test
│ │ ├── java
│ │ └── org
│ │ │ └── apache
│ │ │ └── teaclave
│ │ │ └── javasdk
│ │ │ └── enclave
│ │ │ ├── ConfigMemTest.java
│ │ │ ├── EnclaveTestHelper.java
│ │ │ ├── NativeImageTest.java
│ │ │ ├── NativeImageTestable.java
│ │ │ ├── RunWithNativeImageTest.java
│ │ │ ├── SVMSimpleEnclaveCallTest.java
│ │ │ ├── TestTarget.java
│ │ │ ├── framework
│ │ │ ├── ServiceMethodInvokerTest.java
│ │ │ └── ServiceOperationTest.java
│ │ │ └── testservice
│ │ │ ├── EnclaveMem.java
│ │ │ ├── EncryptionService.java
│ │ │ ├── IntegerMath.java
│ │ │ ├── MathService.java
│ │ │ ├── MemService.java
│ │ │ ├── NumericMath.java
│ │ │ ├── Point.java
│ │ │ ├── PointMath.java
│ │ │ └── SunECOperations.java
│ │ └── resources
│ │ ├── META-INF
│ │ └── services
│ │ │ ├── org.apache.teaclave.javasdk.enclave.testservice.EncryptionService
│ │ │ ├── org.apache.teaclave.javasdk.enclave.testservice.MathService
│ │ │ └── org.apache.teaclave.javasdk.enclave.testservice.MemService
│ │ └── native
│ │ ├── enc_invoke_entry_test.c
│ │ ├── main_c.c
│ │ └── org_apache_teaclave_javasdk_enclave_EnclaveTestHelper.h
├── host
│ ├── docs
│ │ └── Configuration.md
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── org
│ │ │ │ └── apache
│ │ │ │ └── teaclave
│ │ │ │ └── javasdk
│ │ │ │ └── host
│ │ │ │ ├── AbstractEnclave.java
│ │ │ │ ├── AttestationReport.java
│ │ │ │ ├── BaseEnclaveServicesRecycler.java
│ │ │ │ ├── EmbeddedLibOSAttestationReport.java
│ │ │ │ ├── EmbeddedLibOSEnclave.java
│ │ │ │ ├── EmbeddedLibOSEnclaveConfigure.java
│ │ │ │ ├── Enclave.java
│ │ │ │ ├── EnclaveConfigure.java
│ │ │ │ ├── EnclaveDebug.java
│ │ │ │ ├── EnclaveFactory.java
│ │ │ │ ├── EnclaveInfo.java
│ │ │ │ ├── EnclaveInfoMXBean.java
│ │ │ │ ├── EnclaveInfoManager.java
│ │ │ │ ├── EnclaveServicesRecycler.java
│ │ │ │ ├── EnclaveSimulate.java
│ │ │ │ ├── EnclaveToken.java
│ │ │ │ ├── EnclaveType.java
│ │ │ │ ├── ExtractLibrary.java
│ │ │ │ ├── MetricTrace.java
│ │ │ │ ├── MetricTraceContext.java
│ │ │ │ ├── MockEnclaveInfo.java
│ │ │ │ ├── MockInJvmEnclave.java
│ │ │ │ ├── MockInSvmEnclave.java
│ │ │ │ ├── MockInSvmEnclaveConfigure.java
│ │ │ │ ├── ProxyEnclaveInvocationHandler.java
│ │ │ │ ├── ProxyMockJvmInvocationHandler.java
│ │ │ │ ├── RemoteAttestation.java
│ │ │ │ ├── RemoteAttestationVerifyResult.java
│ │ │ │ ├── SGXAttestationReport.java
│ │ │ │ ├── SGXEnclaveInfo.java
│ │ │ │ ├── SGXRemoteAttestationVerify.java
│ │ │ │ ├── TeeSdkAttestationReport.java
│ │ │ │ ├── TeeSdkEnclave.java
│ │ │ │ ├── TeeSdkEnclaveConfigure.java
│ │ │ │ └── exception
│ │ │ │ ├── EnclaveCreatingException.java
│ │ │ │ ├── EnclaveDestroyingException.java
│ │ │ │ ├── EnclaveMethodInvokingException.java
│ │ │ │ ├── EnclaveNativeInvokingException.java
│ │ │ │ ├── MetricTraceLogWriteException.java
│ │ │ │ ├── RemoteAttestationException.java
│ │ │ │ ├── ServicesLoadingException.java
│ │ │ │ └── ServicesUnloadingException.java
│ │ └── native
│ │ │ └── cpp
│ │ │ ├── attestation_verify
│ │ │ └── sgx
│ │ │ │ └── jni
│ │ │ │ ├── Makefile
│ │ │ │ ├── jni_remote_attestation_verify.c
│ │ │ │ └── jni_remote_attestation_verify.h
│ │ │ └── platform
│ │ │ ├── libos_occlum_enclave
│ │ │ └── jni
│ │ │ │ ├── Makefile
│ │ │ │ ├── jni_occlum_enclave.c
│ │ │ │ └── jni_occlum_enclave.h
│ │ │ ├── mock_in_svm
│ │ │ └── jni
│ │ │ │ ├── Makefile
│ │ │ │ ├── jni_mock_in_svm.c
│ │ │ │ └── jni_mock_in_svm.h
│ │ │ └── tee_sdk_svm
│ │ │ ├── Makefile
│ │ │ ├── edge_routines
│ │ │ ├── Makefile
│ │ │ ├── ocall_attestation.c
│ │ │ ├── ocall_attestation.h
│ │ │ ├── ocall_svm.c
│ │ │ └── ocall_svm.h
│ │ │ └── jni
│ │ │ ├── Makefile
│ │ │ ├── generate_attestation_report.c
│ │ │ ├── generate_attestation_report.h
│ │ │ ├── jni_tee_sdk_svm.c
│ │ │ └── jni_tee_sdk_svm.h
│ │ └── test
│ │ └── java
│ │ └── org
│ │ └── apache
│ │ └── teaclave
│ │ └── javasdk
│ │ └── host
│ │ ├── MockTestEnclave.java
│ │ ├── Service.java
│ │ ├── ServiceExceptionTest.java
│ │ ├── ServiceImpl.java
│ │ ├── TestAbstractEnclave.java
│ │ ├── TestEnclaveFactory.java
│ │ └── TestRemoteAttestation.java
├── native
│ ├── bin
│ │ ├── platform
│ │ │ ├── libos_occlum_enclave
│ │ │ │ ├── jni
│ │ │ │ │ └── .gitkeep
│ │ │ │ └── libos_occlum_enclave_attestation
│ │ │ │ │ └── .gitkeep
│ │ │ ├── mock_in_svm
│ │ │ │ └── jni
│ │ │ │ │ └── .gitkeep
│ │ │ └── tee_sdk_svm
│ │ │ │ └── jni
│ │ │ │ └── .gitkeep
│ │ └── remote_attestation
│ │ │ └── sgx
│ │ │ └── jni
│ │ │ └── .gitkeep
│ ├── config
│ │ ├── config.mk
│ │ ├── platform
│ │ │ ├── libos_occlum_enclave
│ │ │ │ ├── enclave
│ │ │ │ │ └── config.mk
│ │ │ │ └── jni
│ │ │ │ │ └── config.mk
│ │ │ ├── mock_in_svm
│ │ │ │ └── jni
│ │ │ │ │ └── config.mk
│ │ │ └── tee_sdk_svm
│ │ │ │ ├── edl
│ │ │ │ ├── tee_sdk_enclave.edl
│ │ │ │ └── tee_sdk_enclave.lds
│ │ │ │ └── jni
│ │ │ │ └── config.mk
│ │ ├── remote_attestation_verify
│ │ │ └── sgx
│ │ │ │ └── config.mk
│ │ └── template
│ │ │ ├── Occlum.json
│ │ │ ├── TeeSDK.conf
│ │ │ └── java_enclave_configure.json
│ ├── include
│ │ ├── enc_environment.h
│ │ └── enc_exported_symbol.h
│ └── script
│ │ ├── build_app
│ │ ├── Makefile
│ │ ├── create_tee_sdk_configure.sh
│ │ ├── libos_occlum_enclave_build.sh
│ │ └── make.sh
│ │ ├── build_enclave_sdk
│ │ ├── Makefile
│ │ └── make.sh
│ │ └── build_host_sdk
│ │ ├── Makefile
│ │ └── make.sh
├── optimizationDetector
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ └── java
│ │ │ └── org
│ │ │ └── apache
│ │ │ └── teaclave
│ │ │ └── javasdk
│ │ │ └── tool
│ │ │ └── optimize
│ │ │ └── ECallInLoopDetector.java
│ │ └── test
│ │ └── java
│ │ └── org
│ │ └── apache
│ │ └── teaclave
│ │ └── javasdk
│ │ └── tool
│ │ └── optimize
│ │ ├── ECallInLoopDetectorTest.java
│ │ ├── LoopCase.java
│ │ └── TestServices.java
└── pom.xml
├── test
├── common
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── org
│ │ └── apache
│ │ └── teaclave
│ │ └── javasdk
│ │ └── test
│ │ └── common
│ │ ├── AESSealedTest.java
│ │ ├── AESService.java
│ │ ├── ConcurrencyCalculate.java
│ │ ├── EnclaveException.java
│ │ ├── EnclaveServiceStatistic.java
│ │ ├── JavaEnclaveException.java
│ │ ├── MetricTraceService.java
│ │ ├── RSAService.java
│ │ ├── ReflectionCallService.java
│ │ ├── SHAService.java
│ │ ├── SM2Service.java
│ │ ├── SM3Service.java
│ │ ├── SM4Service.java
│ │ ├── SMSignAndVerify.java
│ │ └── SayHelloService.java
├── enclave
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── org
│ │ │ │ └── apache
│ │ │ │ └── teaclave
│ │ │ │ └── javasdk
│ │ │ │ └── test
│ │ │ │ └── enclave
│ │ │ │ ├── AESServiceImpl.java
│ │ │ │ ├── AESUtil.java
│ │ │ │ ├── Calculate.java
│ │ │ │ ├── ConcurrencyCalculateImpl.java
│ │ │ │ ├── EnclaveExceptionImpl.java
│ │ │ │ ├── EnclaveServiceStatisticImpl.java
│ │ │ │ ├── MetricTraceServiceImpl.java
│ │ │ │ ├── RSAServiceImpl.java
│ │ │ │ ├── ReflectionCallServiceImpl.java
│ │ │ │ ├── SHAServiceImpl.java
│ │ │ │ ├── SM2ServiceImpl.java
│ │ │ │ ├── SM3ServiceImpl.java
│ │ │ │ ├── SM4ServiceImpl.java
│ │ │ │ ├── SMSignAndVerifyImpl.java
│ │ │ │ └── SayHelloServiceImpl.java
│ │ └── resources
│ │ │ └── META-INF
│ │ │ └── native-image
│ │ │ ├── jni-config.json
│ │ │ ├── proxy-config.json
│ │ │ ├── reflect-config.json
│ │ │ ├── resource-config.json
│ │ │ └── serialization-config.json
│ │ └── test
│ │ └── java
│ │ └── org
│ │ └── apache
│ │ └── teaclave
│ │ └── javasdk
│ │ └── test
│ │ └── enclave
│ │ ├── TestAESServiceImpl.java
│ │ ├── TestEnclaveException.java
│ │ ├── TestEnclaveServiceStatisticImpl.java
│ │ ├── TestReflectionCallService.java
│ │ └── TestSayHelloServiceImpl.java
├── host
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── org
│ │ └── apache
│ │ └── teaclave
│ │ └── javasdk
│ │ └── test
│ │ └── host
│ │ ├── TestEnclaveAES.java
│ │ ├── TestEnclaveConcurrency.java
│ │ ├── TestEnclaveException.java
│ │ ├── TestEnclaveInfo.java
│ │ ├── TestEnclaveInfoMXBean.java
│ │ ├── TestEnclaveMetricTrace.java
│ │ ├── TestEnclaveRSA.java
│ │ ├── TestEnclaveReflection.java
│ │ ├── TestEnclaveSHA.java
│ │ ├── TestEnclaveServiceGC.java
│ │ ├── TestHelloWorld.java
│ │ ├── TestMain.java
│ │ ├── TestRemoteAttestation.java
│ │ └── TestSMEnclave.java
├── pom.xml
└── run.sh
├── third-party-libs
└── bouncycastle-native
│ ├── Makefile
│ ├── README.md
│ ├── bc-java
│ ├── 1.66.gradle7.build.gradle.patch
│ ├── 1.70.build.gradle.patch
│ ├── native-image-agent-access-filter.json
│ └── native-image-agent-caller-filter.json
│ ├── generate_bc_configs.sh
│ ├── make.sh
│ ├── pom.xml
│ └── src
│ ├── main
│ ├── java
│ │ └── org
│ │ │ └── apache
│ │ │ └── teaclave
│ │ │ └── javasdk
│ │ │ └── thirdpartylibs
│ │ │ └── bouncycatsle
│ │ │ ├── BCOptions.java
│ │ │ ├── BouncyCastleFeature.java
│ │ │ └── BouncycastleJarNameFormatException.java
│ └── resources
│ │ ├── META-INF
│ │ ├── native-image
│ │ │ └── org.apache.teaclave.javasdk.thirdpartylibs
│ │ │ │ └── bouncycastle-native
│ │ │ │ └── native-image.properties
│ │ └── services
│ │ │ └── org.graalvm.compiler.options.OptionDescriptors
│ │ └── configs
│ │ ├── 1.66
│ │ ├── core
│ │ │ ├── jni-config.json
│ │ │ ├── predefined-classes-config.json
│ │ │ ├── proxy-config.json
│ │ │ ├── reflect-config.json
│ │ │ ├── resource-config.json
│ │ │ └── serialization-config.json
│ │ ├── mail
│ │ │ ├── jni-config.json
│ │ │ ├── predefined-classes-config.json
│ │ │ ├── proxy-config.json
│ │ │ ├── reflect-config.json
│ │ │ ├── resource-config.json
│ │ │ └── serialization-config.json
│ │ ├── pg
│ │ │ ├── jni-config.json
│ │ │ ├── predefined-classes-config.json
│ │ │ ├── proxy-config.json
│ │ │ ├── reflect-config.json
│ │ │ ├── resource-config.json
│ │ │ └── serialization-config.json
│ │ ├── pkix
│ │ │ ├── jni-config.json
│ │ │ ├── predefined-classes-config.json
│ │ │ ├── proxy-config.json
│ │ │ ├── reflect-config.json
│ │ │ ├── resource-config.json
│ │ │ └── serialization-config.json
│ │ ├── prov
│ │ │ ├── jni-config.json
│ │ │ ├── predefined-classes-config.json
│ │ │ ├── proxy-config.json
│ │ │ ├── reflect-config.json
│ │ │ ├── resource-config.json
│ │ │ └── serialization-config.json
│ │ ├── tls
│ │ │ ├── jni-config.json
│ │ │ ├── predefined-classes-config.json
│ │ │ ├── proxy-config.json
│ │ │ ├── reflect-config.json
│ │ │ ├── resource-config.json
│ │ │ └── serialization-config.json
│ │ └── util
│ │ │ ├── jni-config.json
│ │ │ ├── predefined-classes-config.json
│ │ │ ├── proxy-config.json
│ │ │ ├── reflect-config.json
│ │ │ ├── resource-config.json
│ │ │ └── serialization-config.json
│ │ └── 1.70
│ │ ├── core
│ │ ├── jni-config.json
│ │ ├── predefined-classes-config.json
│ │ ├── proxy-config.json
│ │ ├── reflect-config.json
│ │ ├── resource-config.json
│ │ └── serialization-config.json
│ │ ├── mail
│ │ ├── jni-config.json
│ │ ├── predefined-classes-config.json
│ │ ├── proxy-config.json
│ │ ├── reflect-config.json
│ │ ├── resource-config.json
│ │ └── serialization-config.json
│ │ ├── pg
│ │ ├── jni-config.json
│ │ ├── predefined-classes-config.json
│ │ ├── proxy-config.json
│ │ ├── reflect-config.json
│ │ ├── resource-config.json
│ │ └── serialization-config.json
│ │ ├── pkix
│ │ ├── jni-config.json
│ │ ├── predefined-classes-config.json
│ │ ├── proxy-config.json
│ │ ├── reflect-config.json
│ │ ├── resource-config.json
│ │ └── serialization-config.json
│ │ ├── prov
│ │ ├── jni-config.json
│ │ ├── predefined-classes-config.json
│ │ ├── proxy-config.json
│ │ ├── reflect-config.json
│ │ ├── resource-config.json
│ │ └── serialization-config.json
│ │ ├── tls
│ │ ├── jni-config.json
│ │ ├── predefined-classes-config.json
│ │ ├── proxy-config.json
│ │ ├── reflect-config.json
│ │ ├── resource-config.json
│ │ └── serialization-config.json
│ │ └── util
│ │ ├── jni-config.json
│ │ ├── predefined-classes-config.json
│ │ ├── proxy-config.json
│ │ ├── reflect-config.json
│ │ ├── resource-config.json
│ │ └── serialization-config.json
│ └── test
│ ├── java
│ └── org
│ │ └── apache
│ │ └── teaclave
│ │ └── javasdk
│ │ └── thirdpartylibs
│ │ └── bouncycatsle
│ │ ├── BcService.java
│ │ ├── BcServiceImpl.java
│ │ ├── BouncyCastleTest.java
│ │ ├── Sm2Service.java
│ │ └── Sm2ServiceImpl.java
│ └── resources
│ └── META-INF
│ └── services
│ └── org.apache.teaclave.javasdk.thirdpartylibs.bouncycatsle.BcService
└── tools
└── cicd
├── anolis-8.6
├── dockerfile_build
├── dockerfile_release
├── graalvm
│ ├── build_graalvm_jdk.sh
│ └── make.sh
├── make.sh
└── teesdk
│ ├── build_tee_sdk.sh
│ └── make.sh
├── jenkinsfile
└── ubuntu-18.04
├── dockerfile_build
├── dockerfile_release
├── graalvm
├── build_graalvm_jdk.sh
└── make.sh
├── make.sh
└── teesdk
├── build_tee_sdk.sh
└── make.sh
/.asf.yaml:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one or more
2 | # contributor license agreements. See the NOTICE file distributed with
3 | # this work for additional information regarding copyright ownership.
4 | # The ASF licenses this file to You under the Apache License, Version 2.0
5 | # (the "License"); you may not use this file except in compliance with
6 | # the License. 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 | github:
17 | description: "Apache Teaclave (incubating) Java TEE SDK is an open source universal confidential computing framework, making java computation on privacy-sensitive data safe and simple."
18 | homepage: https://teaclave.apache.org
19 | labels:
20 | - confidential-computing
21 | - trusted-execution-environment
22 | - tee
23 | - sgx
24 | - java
25 | - graalvm
26 | features:
27 | issues: true
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 |
4 | # Log file
5 | *.log
6 |
7 |
8 | # virtual machine crash logs
9 | hs_err_pid*
10 |
11 | # IDE config
12 | *.iml
13 | .idea/
14 | .classpath
15 | .project
16 | .settings/
17 | .vscode
18 |
19 | # Maven compiled directory
20 | target/
21 |
--------------------------------------------------------------------------------
/DISCLAIMER-WIP:
--------------------------------------------------------------------------------
1 | Apache Teaclave Java TEE SDK (incubating) is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Apache Incubator.
2 | Incubation is required of all newly accepted projects until a further review
3 | indicates that the infrastructure, communications, and decision making process
4 | have stabilized in a manner consistent with other successful ASF projects.
5 | While incubation status is not necessarily a reflection of the completeness or
6 | stability of the code, it does indicate that the project has yet to be fully
7 | endorsed by the ASF.
8 |
9 | Some of the incubating project’s releases may not be fully compliant with ASF
10 | policy. For example, releases may have incomplete or un-reviewed licensing
11 | conditions. What follows is a list of known issues the project is currently
12 | aware of (note that this list, by definition, is likely to be incomplete):
13 |
14 | * Releases may have incomplete licensing conditions.
15 |
16 | If you are planning to incorporate this work into your product/project, please
17 | be aware that you will need to conduct a thorough licensing review to determine
18 | the overall implications of including this work. For the current status of this
19 | project through the Apache Incubator visit:
20 | https://incubator.apache.org/projects/teaclave.html
--------------------------------------------------------------------------------
/NOTICE:
--------------------------------------------------------------------------------
1 | Apache Teaclave (incubating)
2 | Copyright 2019-2023 The Apache Software Foundation
3 |
4 | This product includes software developed at
5 | The Apache Software Foundation (http://www.apache.org/).
6 |
--------------------------------------------------------------------------------
/archetype/src/main/resources/archetype-resources/enclave/src/main/resources/META-INF/native-image/jni-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/archetype/src/main/resources/archetype-resources/enclave/src/main/resources/META-INF/native-image/proxy-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/archetype/src/main/resources/archetype-resources/enclave/src/main/resources/META-INF/native-image/reflect-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
--------------------------------------------------------------------------------
/archetype/src/main/resources/archetype-resources/enclave/src/main/resources/META-INF/native-image/resource-config.json:
--------------------------------------------------------------------------------
1 | {
2 | "resources":{
3 | "includes":[]},
4 | "bundles":[]
5 | }
6 |
--------------------------------------------------------------------------------
/archetype/src/main/resources/archetype-resources/enclave/src/main/resources/META-INF/native-image/serialization-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/archetype/src/test/resources/projects/basic/archetype.properties:
--------------------------------------------------------------------------------
1 | #Mon Jun 28 12:07:27 CST 2021
2 | package=it.pkg
3 | groupId=archetype.it
4 | artifactId=basic
5 | version=0.1.0
6 |
--------------------------------------------------------------------------------
/archetype/src/test/resources/projects/basic/goal.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/incubator-teaclave-java-tee-sdk/6dced3005c4ef7585d2f28c82f6dbcab8a5d7357/archetype/src/test/resources/projects/basic/goal.txt
--------------------------------------------------------------------------------
/benchmark/guomi/common/src/main/java/org/apache/teaclave/javasdk/benchmark/guomi/common/SMService.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.benchmark.guomi.common;
19 |
20 | import org.apache.teaclave.javasdk.common.annotations.EnclaveService;
21 |
22 | @EnclaveService
23 | public interface SMService {
24 | String sm2Service(String plaintext, int weight) throws Exception;
25 | byte[] sm3Service(String plainText, int weight) throws Exception;
26 | String sm4Service(String plaintext, int weight) throws Exception;
27 | }
28 |
--------------------------------------------------------------------------------
/benchmark/guomi/enclave/src/main/java/org/apache/teaclave/javasdk/benchmark/guomi/enclave/SM3ServiceImpl.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.benchmark.guomi.enclave;
19 |
20 | import org.bouncycastle.crypto.Digest;
21 | import org.bouncycastle.crypto.digests.SM3Digest;
22 |
23 | class SM3ServiceImpl {
24 | byte[] sm3Service(String plainText) throws Exception {
25 | byte[] messages = plainText.getBytes();
26 | Digest md = new SM3Digest();
27 | md.update(messages, 0, messages.length);
28 | byte[] digest = new byte[md.getDigestSize()];
29 | md.doFinal(digest, 0);
30 | return digest;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/benchmark/guomi/enclave/src/main/resources/META-INF/native-image/jni-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/benchmark/guomi/enclave/src/main/resources/META-INF/native-image/proxy-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/benchmark/guomi/enclave/src/main/resources/META-INF/native-image/reflect-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
--------------------------------------------------------------------------------
/benchmark/guomi/enclave/src/main/resources/META-INF/native-image/resource-config.json:
--------------------------------------------------------------------------------
1 | {
2 | "resources":{
3 | "includes":[]},
4 | "bundles":[]
5 | }
6 |
--------------------------------------------------------------------------------
/benchmark/guomi/enclave/src/main/resources/META-INF/native-image/serialization-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/benchmark/guomi/enclave/src/main/resources/java_enclave_configure.json:
--------------------------------------------------------------------------------
1 | {
2 | "debuggable": false,
3 | "enclave_type": "TEE_SDK",
4 | "metric_trace_enable": false,
5 | "metric_trace_file_path": "",
6 | "enclave_max_thread": 50,
7 | "enclave_max_epc_memory_size_MB": 2500
8 | }
--------------------------------------------------------------------------------
/benchmark/guomi/run.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 |
20 | mvn -Pnative clean package
21 |
22 | OCCLUM_RELEASE_ENCLAVE=true $JAVA_HOME/bin/java -Dorg.apache.teaclave.javasdk.enclave.metric.enable=false -cp host/target/host-1.0-SNAPSHOT-jar-with-dependencies.jar:enclave/target/enclave-1.0-SNAPSHOT-jar-with-dependencies.jar org.apache.teaclave.javasdk.benchmark.guomi.host.GuoMiBenchMark
23 |
--------------------------------------------------------------------------------
/benchmark/string/common/src/main/java/org/apache/teaclave/javasdk/benchmark/string/common/StringOperationMetric.java:
--------------------------------------------------------------------------------
1 | package org.apache.teaclave.javasdk.benchmark.string.common;
2 |
3 | import org.apache.teaclave.javasdk.common.annotations.EnclaveService;
4 |
5 | @EnclaveService
6 | public interface StringOperationMetric {
7 | boolean stringRegex(String source, String pattern, int weight);
8 | String stringConcat(String source, String split, int weight);
9 | String[] stringSplit(String source, String concat, int weight);
10 | }
11 |
--------------------------------------------------------------------------------
/benchmark/string/enclave/src/main/java/org/apache/teaclave/javasdk/benchmark/string/enclave/StringOperationMetricImpl.java:
--------------------------------------------------------------------------------
1 | package org.apache.teaclave.javasdk.benchmark.string.enclave;
2 |
3 | import org.apache.teaclave.javasdk.benchmark.string.common.StringOperationMetric;
4 | import com.google.auto.service.AutoService;
5 |
6 | import java.util.regex.Pattern;
7 |
8 | @AutoService(StringOperationMetric.class)
9 | public class StringOperationMetricImpl implements StringOperationMetric {
10 |
11 | @Override
12 | public String stringConcat(String source, String concat, int weight) {
13 | String result = null;
14 | for (int i = 0x0; i < weight; i++) {
15 | result = source.concat(concat).toLowerCase().trim().replace('a', 'b');
16 | }
17 | return result;
18 | }
19 |
20 | @Override
21 | public boolean stringRegex(String source, String pattern, int weight) {
22 | boolean matched = false;
23 | for (int i = 0x0; i < weight; i++) {
24 | Pattern p = Pattern.compile(pattern);
25 | matched = p.matcher(source).matches();
26 | }
27 | return matched;
28 | }
29 |
30 | @Override
31 | public String[] stringSplit(String source, String split, int weight) {
32 | String[] result = null;
33 | for (int i = 0x0; i < weight; i++) {
34 | result = source.split(split);
35 | }
36 | return result;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/benchmark/string/enclave/src/main/resources/META-INF/native-image/jni-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/benchmark/string/enclave/src/main/resources/META-INF/native-image/proxy-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/benchmark/string/enclave/src/main/resources/META-INF/native-image/reflect-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
--------------------------------------------------------------------------------
/benchmark/string/enclave/src/main/resources/META-INF/native-image/resource-config.json:
--------------------------------------------------------------------------------
1 | {
2 | "resources":{
3 | "includes":[]},
4 | "bundles":[]
5 | }
6 |
--------------------------------------------------------------------------------
/benchmark/string/enclave/src/main/resources/META-INF/native-image/serialization-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/benchmark/string/enclave/src/main/resources/java_enclave_configure.json:
--------------------------------------------------------------------------------
1 | {
2 | "debuggable": false,
3 | "enclave_type": "TEE_SDK",
4 | "metric_trace_enable": false,
5 | "metric_trace_file_path": "",
6 | "enclave_max_thread": 50,
7 | "enclave_max_epc_memory_size_MB": 2000
8 | }
--------------------------------------------------------------------------------
/benchmark/string/run.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | mvn -Pnative clean package
4 |
5 | OCCLUM_RELEASE_ENCLAVE=true $JAVA_HOME/bin/java -Dorg.apache.teaclave.javasdk.enclave.metric.enable=false -cp host/target/host-1.0-SNAPSHOT-jar-with-dependencies.jar:enclave/target/enclave-1.0-SNAPSHOT-jar-with-dependencies.jar org.apache.teaclave.javasdk.benchmark.string.host.StringBenchMark
6 |
--------------------------------------------------------------------------------
/docs/resources/JavaEnclave_Application_Dependency.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/incubator-teaclave-java-tee-sdk/6dced3005c4ef7585d2f28c82f6dbcab8a5d7357/docs/resources/JavaEnclave_Application_Dependency.png
--------------------------------------------------------------------------------
/docs/resources/JavaEnclave_Architecture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/incubator-teaclave-java-tee-sdk/6dced3005c4ef7585d2f28c82f6dbcab8a5d7357/docs/resources/JavaEnclave_Architecture.png
--------------------------------------------------------------------------------
/docs/resources/JavaEnclave_Project_Structure.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/incubator-teaclave-java-tee-sdk/6dced3005c4ef7585d2f28c82f6dbcab8a5d7357/docs/resources/JavaEnclave_Project_Structure.png
--------------------------------------------------------------------------------
/docs/resources/SGX2_Supported_Check.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/incubator-teaclave-java-tee-sdk/6dced3005c4ef7585d2f28c82f6dbcab8a5d7357/docs/resources/SGX2_Supported_Check.png
--------------------------------------------------------------------------------
/licenses/LICENSE-bouncycastle.txt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Copyright (c) 2000-2021 The Legion of the Bouncy Castle Inc. (https://www.bouncycastle.org)
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software
7 | and associated documentation files (the "Software"), to deal in the Software without restriction,
8 | including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 | and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all copies or substantial
13 | portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
17 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | DEALINGS IN THE SOFTWARE.
21 |
22 |
--------------------------------------------------------------------------------
/licenses/LICENSE-sgx-sdk.txt:
--------------------------------------------------------------------------------
1 |
2 | BSD License
3 |
4 | Copyright (C) 2011-2021 Intel Corporation. All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions
8 | are met:
9 |
10 | * Redistributions of source code must retain the above copyright
11 | notice, this list of conditions and the following disclaimer.
12 | * Redistributions in binary form must reproduce the above copyright
13 | notice, this list of conditions and the following disclaimer in
14 | the documentation and/or other materials provided with the
15 | distribution.
16 | * Neither the name of Intel Corporation nor the names of its
17 | contributors may be used to endorse or promote products derived
18 | from this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
/samples/helloworld/common/src/main/java/org/apache/teaclave/javasdk/samples/helloworld/common/Service.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.samples.helloworld.common;
19 |
20 | import org.apache.teaclave.javasdk.common.annotations.EnclaveService;
21 |
22 | @EnclaveService
23 | public interface Service {
24 | String sayHelloWorld();
25 | }
26 |
--------------------------------------------------------------------------------
/samples/helloworld/enclave/src/main/java/org/apache/teaclave/samples/helloworld/enclave/ServiceImpl.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.samples.helloworld.enclave;
19 |
20 | import org.apache.teaclave.javasdk.samples.helloworld.common.Service;
21 | import com.google.auto.service.AutoService;
22 |
23 | @AutoService(Service.class)
24 | public class ServiceImpl implements Service {
25 | @Override
26 | public String sayHelloWorld() {
27 | return "Hello World";
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/samples/helloworld/enclave/src/main/resources/META-INF/native-image/jni-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/samples/helloworld/enclave/src/main/resources/META-INF/native-image/proxy-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/samples/helloworld/enclave/src/main/resources/META-INF/native-image/reflect-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
--------------------------------------------------------------------------------
/samples/helloworld/enclave/src/main/resources/META-INF/native-image/resource-config.json:
--------------------------------------------------------------------------------
1 | {
2 | "resources":{
3 | "includes":[]},
4 | "bundles":[]
5 | }
6 |
--------------------------------------------------------------------------------
/samples/helloworld/enclave/src/main/resources/META-INF/native-image/serialization-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/samples/helloworld/host/src/main/java/org/apache/teaclave/javasdk/samples/helloworld/host/Main.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.samples.helloworld.host;
19 |
20 | import org.apache.teaclave.javasdk.host.Enclave;
21 | import org.apache.teaclave.javasdk.host.EnclaveFactory;
22 | import org.apache.teaclave.javasdk.host.EnclaveType;
23 | import org.apache.teaclave.javasdk.samples.helloworld.common.Service;
24 |
25 | import java.util.Iterator;
26 |
27 | public class Main {
28 | public static void main(String[] args) throws Exception {
29 | EnclaveType[] enclaveTypes = {
30 | EnclaveType.MOCK_IN_JVM,
31 | EnclaveType.MOCK_IN_SVM,
32 | EnclaveType.TEE_SDK};
33 |
34 | for (EnclaveType enclaveType : enclaveTypes) {
35 | Enclave enclave = EnclaveFactory.create(enclaveType);
36 | Iterator services = enclave.load(Service.class);
37 | System.out.println(services.next().sayHelloWorld());
38 | enclave.destroy();
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/samples/helloworld/run.sh:
--------------------------------------------------------------------------------
1 | #/bin/bash
2 |
3 | mvn -Pnative clean package
4 |
5 | OCCLUM_RELEASE_ENCLAVE=true $JAVA_HOME/bin/java -cp host/target/host-1.0-SNAPSHOT-jar-with-dependencies.jar:enclave/target/enclave-1.0-SNAPSHOT-jar-with-dependencies.jar org.apache.teaclave.javasdk.samples.helloworld.host.Main
6 |
--------------------------------------------------------------------------------
/samples/springboot/common/src/main/java/org/apache/teaclave/javasdk/samples/springboot/common/SBEnclaveService.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.samples.springboot.common;
19 |
20 | import org.apache.teaclave.javasdk.common.annotations.EnclaveService;
21 |
22 | @EnclaveService
23 | public interface SBEnclaveService {
24 | // calculate giving data's digest.
25 | String digestData(String data);
26 | // encrypt and decrypt giving string.
27 | String encryptAndDecryptData(String data);
28 | }
29 |
--------------------------------------------------------------------------------
/samples/springboot/enclave/src/main/resources/META-INF/native-image/jni-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/samples/springboot/enclave/src/main/resources/META-INF/native-image/proxy-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/samples/springboot/enclave/src/main/resources/META-INF/native-image/reflect-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
--------------------------------------------------------------------------------
/samples/springboot/enclave/src/main/resources/META-INF/native-image/resource-config.json:
--------------------------------------------------------------------------------
1 | {
2 | "resources":{
3 | "includes":[]},
4 | "bundles":[]
5 | }
6 |
--------------------------------------------------------------------------------
/samples/springboot/enclave/src/main/resources/META-INF/native-image/serialization-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/samples/springboot/host/src/main/java/org/apache/teaclave/javasdk/samples/springboot/host/Application.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.samples.springboot.host;
19 |
20 | import java.util.Arrays;
21 |
22 | import org.springframework.boot.CommandLineRunner;
23 | import org.springframework.boot.SpringApplication;
24 | import org.springframework.boot.autoconfigure.SpringBootApplication;
25 | import org.springframework.context.ApplicationContext;
26 | import org.springframework.context.annotation.Bean;
27 |
28 | @SpringBootApplication
29 | public class Application {
30 |
31 | public static void main(String[] args) {
32 | SpringApplication.run(Application.class, args);
33 | }
34 |
35 | @Bean
36 | public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
37 | return args -> {
38 | String[] beanNames = ctx.getBeanDefinitionNames();
39 | Arrays.sort(beanNames);
40 | };
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/samples/springboot/run.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 |
20 | # step1: build springboot application service.
21 | mvn -Pnative clean package
22 |
23 | # step2: startup springboot application service.
24 | OCCLUM_RELEASE_ENCLAVE=true $JAVA_HOME/bin/java -cp host/target/host-1.0-SNAPSHOT-jar-with-dependencies.jar:enclave/target/enclave-1.0-SNAPSHOT-jar-with-dependencies.jar org.apache.teaclave.javasdk.samples.springboot.host.Application &
25 | sleep 5
26 | # shellcheck disable=SC2006
27 | # shellcheck disable=SC2009
28 | PID=`ps -ef | grep "Application" | grep -v grep | awk '{print $2}'`
29 |
30 | # step3: encrypt and decrypt service.
31 | wget http://localhost:8080/enclaveEncDecService?data=SELECT+TOP+50+PERCENT+*+FROM+Websites;
32 |
33 | # step4: digest service.
34 | wget http://localhost:8080/enclaveDigestService?data=SELECT+TOP+50+PERCENT+*+FROM+Websites;
35 |
36 | # step5: kill springboot service.
37 | kill -9 "$PID"
--------------------------------------------------------------------------------
/sdk/common/src/main/java/org/apache/teaclave/javasdk/common/annotations/EnclaveMethod.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.common.annotations;
19 |
20 | import java.lang.annotation.ElementType;
21 | import java.lang.annotation.Retention;
22 | import java.lang.annotation.RetentionPolicy;
23 | import java.lang.annotation.Target;
24 |
25 | /**
26 | * Mark a method is running inside the Enclave, but can be directly invoked from the Host.
27 | * So its parameters and returned value types are required to get serialized.
28 | * If a service provider's interface has been marked with {@link EnclaveService}, there is no need to mark its methods with
29 | * this annotation.
30 | *
31 | * Please refer {@link EnclaveService} for the details about automatic serialization type registration in native image scenario.
32 | */
33 | @Target(ElementType.METHOD)
34 | @Retention(RetentionPolicy.RUNTIME)
35 | public @interface EnclaveMethod {
36 | }
37 |
--------------------------------------------------------------------------------
/sdk/enclave/src/main/java/org/apache/teaclave/javasdk/enclave/EnclavePrologue.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.enclave;
19 |
20 | import com.oracle.svm.core.annotate.Uninterruptible;
21 | import com.oracle.svm.core.c.CGlobalData;
22 | import com.oracle.svm.core.c.CGlobalDataFactory;
23 | import com.oracle.svm.core.c.function.CEntryPointActions;
24 | import com.oracle.svm.core.c.function.CEntryPointOptions;
25 | import org.graalvm.nativeimage.Isolate;
26 | import org.graalvm.nativeimage.c.type.CCharPointer;
27 |
28 | public class EnclavePrologue implements CEntryPointOptions.Prologue {
29 | private static final CGlobalData errorMessage = CGlobalDataFactory.createCString("Failed to enter (or attach to) the global isolate in the current thread.");
30 |
31 | @Uninterruptible(reason = "prologue")
32 | static void enter(Isolate isolate) {
33 |
34 | int code = CEntryPointActions.enterAttachThread(isolate, true);
35 | if (code != 0) {
36 | CEntryPointActions.failFatally(code, errorMessage.get());
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/sdk/enclave/src/main/java/org/apache/teaclave/javasdk/enclave/EnclaveRandomFeature.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.enclave;
19 |
20 | import com.oracle.svm.core.annotate.AutomaticFeature;
21 | import com.oracle.svm.hosted.FeatureHandler;
22 | import com.oracle.svm.hosted.FeatureImpl;
23 | import org.graalvm.nativeimage.hosted.Feature;
24 |
25 | @AutomaticFeature
26 | public class EnclaveRandomFeature implements Feature {
27 | @Override
28 | public void afterRegistration(Feature.AfterRegistrationAccess access) {
29 | if (EnclaveOptions.RunInEnclave.getValue()) {
30 | FeatureImpl.AfterRegistrationAccessImpl a = (FeatureImpl.AfterRegistrationAccessImpl) access;
31 | FeatureHandler featureHandler = a.getFeatureHandler();
32 | EnclavePlatFormSettings.disableFeatures(featureHandler, "com.oracle.svm.core.posix.NativeSecureRandomFilesCloser");
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/sdk/enclave/src/main/java/org/apache/teaclave/javasdk/enclave/framework/EnclaveMethodInvoker.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.enclave.framework;
19 |
20 | import org.apache.teaclave.javasdk.common.EnclaveInvocationResult;
21 |
22 | /**
23 | * There are two types of method invocations in Enclave:
24 | *
25 | * - Business methods: The subclass {@link ServiceMethodInvoker} of this class takes care
26 | * of the business method invocation.
27 | * - Framework methods: The SDK defined methods that run inside the enclave to maintain the framework. These methods
28 | * must be static, are taken care by the subclass {@link LoadServiceInvoker}.
29 | *
30 | */
31 | public interface EnclaveMethodInvoker {
32 | EnclaveInvocationResult callMethod(T input);
33 | }
34 |
--------------------------------------------------------------------------------
/sdk/enclave/src/main/java/org/apache/teaclave/javasdk/enclave/framework/LoadServiceInvoker.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.enclave.framework;
19 |
20 | import org.apache.teaclave.javasdk.common.EnclaveInvocationResult;
21 |
22 | /**
23 | * This class handles loadService method invocation.
24 | */
25 | public final class LoadServiceInvoker implements EnclaveMethodInvoker {
26 |
27 | /**
28 | * Call loadService method.
29 | *
30 | * @param inputData name of the service to load.
31 | */
32 | @Override
33 | public EnclaveInvocationResult callMethod(String inputData) {
34 | try {
35 | Class> service = Class.forName(inputData);
36 | return new EnclaveInvocationResult(EnclaveContext.getInstance().loadService(service), null);
37 | } catch (ClassNotFoundException e) {
38 | return new EnclaveInvocationResult(null, e);
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/sdk/enclave/src/main/native/cpp/platform/libos_occlum_enclave/remote_attestation_generate/Makefile:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | include $(NATIVE_BASE_DIR)/config/config.mk
19 | include $(NATIVE_BASE_DIR)/config/platform/libos_occlum_enclave/enclave/config.mk
20 |
21 | .PHONY: all build clean
22 |
23 | all: build
24 |
25 | build:
26 | $(CC) jni_occlum_attestation_generate.c -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/$(shell uname -s | tr A-Z a-z) \
27 | -I$(INCPATH) -I$(TEE_SDK_PATH)/include -L$(LIBPATH) -locclum_dcap -fPIC -shared \
28 | -o $(BIN)/platform/libos_occlum_enclave/libos_occlum_enclave_attestation/lib_occlum_attestation_generate.so
29 |
30 | clean:
31 | rm -rf $(BIN)/platform/libos_occlum_enclave/libos_occlum_enclave_attestation/lib_occlum_attestation_generate.so
--------------------------------------------------------------------------------
/sdk/enclave/src/main/native/cpp/platform/tee_sdk_svm/edge_routines/Makefile:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | include $(NATIVE_BASE_DIR)/config/config.mk
19 | include $(NATIVE_BASE_DIR)/config/platform/tee_sdk_svm/jni/config.mk
20 |
21 | .PHONY: all build clean
22 |
23 | all: build
24 |
25 | build:
26 | $(SGX_EDGER8R) $(CONFIG)/platform/tee_sdk_svm/edl/tee_sdk_enclave.edl --trusted --search-path $(TEE_SDK_PATH)/include
27 | $(CC) -g -c -std=c99 -I$(INCLUDE) $(TS_ENCLAVE_INCDIR) $(TS_ENCLAVE_CFLAGS) tee_sdk_enclave_t.c sgx_mmap.c tee_sdk_symbol.c
28 |
29 | mv *.o $(BIN)/platform/tee_sdk_svm/
30 |
31 | rm -rf tee_sdk_enclave_t.*
32 |
33 | clean:
34 | rm -rf $(BIN)/platform/tee_sdk_svm/wrapper/*.o
35 | rm -rf tee_sdk_svm_*
--------------------------------------------------------------------------------
/sdk/enclave/src/main/native/cpp/platform/tee_sdk_svm/edge_routines/sgx_mmap.h:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | #include "tee_sdk_enclave_t.h"
19 | #include "tee_sdk_symbol.h"
20 |
21 | #ifndef _SGX_MMAP_H_
22 | #define _SGX_MMAP_H_
23 |
24 | long physical_page_size();
25 | long physical_page_number();
26 | long virtual_page_size();
27 | void* mmap(void *hint, int size, int prot, int flags);
28 | int munmap(void *addr, int size);
29 | extern void* _mmap(void *addr, size_t length, int prot, int flags, int fd, int offset);
30 | extern int _munmap(void *addr, size_t len);
31 | extern size_t get_heap_size(void);
32 |
33 | #endif /* !_SGX_MMAP_H_ */
--------------------------------------------------------------------------------
/sdk/enclave/src/main/native/cpp/platform/tee_sdk_svm/remote_attestation_generate/Makefile:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | include $(NATIVE_BASE_DIR)/config/config.mk
19 | include $(NATIVE_BASE_DIR)/config/platform/tee_sdk_svm/jni/config.mk
20 |
21 | .PHONY: all build clean
22 |
23 | all: build
24 |
25 | build:
26 | $(CC) -g -c -I$(INCLUDE) -I$(JAVA_HOME)/lib $(TS_ENCLAVE_INCDIR) $(TS_ENCLAVE_CFLAGS) generate_attestation_report.c \
27 | -o $(BIN)/platform/tee_sdk_svm/generate_attestation_report.o
28 |
29 | clean:
30 | rm -rf $(BIN)/platform/tee_sdk_svm/generate_attestation_report.o
--------------------------------------------------------------------------------
/sdk/enclave/src/main/native/cpp/platform/tee_sdk_svm/remote_attestation_generate/generate_attestation_report.c:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | #include "generate_attestation_report.h"
19 |
20 | int generate_remote_attestation_report(void* hash, size_t hash_length, sgx_report_t* ra_report) {
21 | sgx_report_data_t report_data;
22 | quote3_error_t sgx_error;
23 | if (hash_length != SGX_REPORT_DATA_SIZE) {
24 | return (int)SGX_ERROR_INVALID_PARAMETER;
25 | }
26 | memset(&report_data, 0, sizeof(sgx_report_data_t));
27 | memcpy(report_data.d, hash, SGX_REPORT_DATA_SIZE);
28 |
29 | sgx_target_info_t qe_target_info;
30 | memset(&qe_target_info, 0, sizeof(sgx_target_info_t));
31 |
32 | ocall_get_target_info(&sgx_error, &qe_target_info);
33 | if(sgx_error != SGX_QL_SUCCESS) {
34 | return (int)sgx_error;
35 | }
36 |
37 | /* Generate the report for the app_enclave */
38 | return (int)sgx_create_report(&qe_target_info, &report_data, ra_report);
39 | }
40 |
--------------------------------------------------------------------------------
/sdk/enclave/src/main/native/cpp/platform/tee_sdk_svm/remote_attestation_generate/generate_attestation_report.h:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | #ifndef _GENERATE_ATTESTATION_REPORT_H_
19 | #define _GENERATE_ATTESTATION_REPORT_H_
20 |
21 | #include
22 | #include
23 | #include
24 |
25 | #include "sgx_trts.h"
26 | #include "sgx_error.h"
27 | #include "sgx_report.h"
28 | #include "sgx_utils.h"
29 | #include "sgx_quote_3.h"
30 | #include "sgx_ql_lib_common.h"
31 |
32 | #if defined(__cplusplus)
33 | extern "C"
34 | {
35 | #endif
36 | int generate_remote_attestation_report(void* hash, size_t hash_length, sgx_report_t* ra_report);
37 | #if defined(__cplusplus)
38 | }
39 | #endif
40 |
41 | #endif /* !_GENERATE_ATTESTATION_REPORT_H_ */
42 |
--------------------------------------------------------------------------------
/sdk/enclave/src/main/native/cpp/platform/tee_sdk_svm/wrapper/Makefile:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | include $(NATIVE_BASE_DIR)/config/config.mk
19 | include $(NATIVE_BASE_DIR)/config/platform/tee_sdk_svm/jni/config.mk
20 |
21 | .PHONY: all build clean
22 |
23 | all: build
24 |
25 | build:
26 | $(CC) -g -c -I$(INCLUDE) -I../edge_routines -I$(JAVA_HOME)/lib $(TS_ENCLAVE_INCDIR) $(TS_ENCLAVE_CFLAGS) tee_sdk_wrapper.c \
27 | -o $(BIN)/platform/tee_sdk_svm/tee_sdk_wrapper.o
28 |
29 | clean:
30 | rm -rf $(BIN)/platform/tee_sdk_svm/tee_sdk_wrapper.o
--------------------------------------------------------------------------------
/sdk/enclave/src/main/native/cpp/platform/tee_sdk_svm/wrapper/tee_sdk_wrapper.h:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | #ifndef _TEE_SDK_WRAPPER_H_
19 | #define _TEE_SDK_WRAPPER_H_
20 |
21 | #include
22 | #include
23 | #include
24 |
25 | #if defined(__cplusplus)
26 | extern "C"
27 | {
28 | #endif
29 | void ocall_malloc(int*, int, void*);
30 | #if defined(__cplusplus)
31 | }
32 | #endif
33 |
34 | #endif /* !_TEE_SDK_WRAPPER_H_ */
--------------------------------------------------------------------------------
/sdk/enclave/src/main/resources/META-INF/native-image/reflect-config.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "java.security.MessageDigestSpi"
4 | },
5 | {
6 | "name": "[Ljava.lang.Object;"
7 | },
8 | {
9 | "name": "[Ljava.lang.String;"
10 | },
11 | {
12 | "name": "sun.security.provider.SHA",
13 | "methods": [
14 | {
15 | "name": "",
16 | "parameterTypes": []
17 | }
18 | ]
19 | }
20 | ]
21 |
--------------------------------------------------------------------------------
/sdk/enclave/src/main/resources/META-INF/native-image/serialization-config.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name":"org.apache.teaclave.javasdk.common.EnclaveInvocationContext"
4 | },
5 | {
6 | "name":"org.apache.teaclave.javasdk.common.EnclaveInvocationResult"
7 | },
8 | {
9 | "name":"org.apache.teaclave.javasdk.common.ServiceHandler"
10 | },
11 | {
12 | "name": "[Lorg.apache.teaclave.javasdk.common.ServiceHandler;"
13 | },
14 | {
15 | "name":"java.lang.String"
16 | },
17 | {
18 | "name":"java.util.ArrayList"
19 | },
20 | {
21 | "name": "java.util.Arrays$ArrayList"
22 | },
23 | {
24 | "name":"java.lang.Throwable"
25 | },
26 | {
27 | "name":"java.lang.Error"
28 | },
29 | {
30 | "name":"java.lang.Exception"
31 | },
32 | {
33 | "name":"java.io.IOException"
34 | },
35 | {
36 | "name":"java.lang.ClassCastException"
37 | },
38 | {
39 | "name":"java.lang.reflect.InvocationTargetException"
40 | },
41 | {
42 | "name":"java.lang.NullPointerException"
43 | },
44 | {
45 | "name":"java.io.ObjectStreamException"
46 | },
47 | {
48 | "name":"java.io.NotSerializableException"
49 | },
50 | {
51 | "name":"java.io.StreamCorruptedException"
52 | },
53 | {
54 | "name":"java.lang.StackTraceElement"
55 | },
56 | {
57 | "name":"[Ljava.lang.StackTraceElement;"
58 | },
59 | {
60 | "name":"java.lang.Number"
61 | }
62 | ]
63 |
--------------------------------------------------------------------------------
/sdk/enclave/src/main/resources/META-INF/services/org.graalvm.compiler.options.OptionDescriptors:
--------------------------------------------------------------------------------
1 | org.apache.teaclave.javasdk.enclave.EnclaveOptions_OptionDescriptors
2 |
--------------------------------------------------------------------------------
/sdk/enclave/src/main/resources/native/enc_environment.h:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | typedef struct enc_data_struct{
19 | //char array is used as byte array to store serialized data
20 | char* data;
21 | int data_len;
22 | } enc_data_t;
23 |
24 | typedef struct callback_functions_struct{
25 | /*
26 | * This method is invoked inside java_enclave_invoke method's exception catch
27 | * section, when the execution is aborted by exceptions. The caller side can
28 | * decide what to do with the exception.
29 | * Exception details are passed back with parameters.
30 | */
31 | void (*exception_handler)(char* err_msg, char* stack_trace, char* exception_name);
32 |
33 | char* (*memcpy_char_pointer)(char* src, int len);
34 |
35 | /*
36 | * Points to an available pseudorandom number generating function.
37 | */
38 | int (*get_random_number)(void* data, long size);
39 | } callbacks_t;
40 |
41 | long physical_page_size();
42 | long physical_page_number();
43 | long virtual_page_size();
44 |
--------------------------------------------------------------------------------
/sdk/enclave/src/test/java/org/apache/teaclave/javasdk/enclave/NativeImageTestable.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.enclave;
19 |
20 | import java.util.List;
21 |
22 | public interface NativeImageTestable {
23 | default void runWithNativeImageAgent(){}
24 | default void beforeSVMCompile(){}
25 | default void afterSVMCompile(){}
26 | default List extraSVMOptions() {
27 | return null;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/sdk/enclave/src/test/java/org/apache/teaclave/javasdk/enclave/TestTarget.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.enclave;
19 |
20 | import java.lang.annotation.ElementType;
21 | import java.lang.annotation.Retention;
22 | import java.lang.annotation.RetentionPolicy;
23 | import java.lang.annotation.Target;
24 |
25 | @Target(ElementType.TYPE)
26 | @Retention(RetentionPolicy.RUNTIME)
27 | public @interface TestTarget {
28 | Class> value();
29 | }
30 |
--------------------------------------------------------------------------------
/sdk/enclave/src/test/java/org/apache/teaclave/javasdk/enclave/testservice/EnclaveMem.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.enclave.testservice;
19 |
20 | import com.oracle.svm.core.heap.PhysicalMemory;
21 |
22 | public class EnclaveMem implements MemService{
23 | @Override
24 | public long getSize() {
25 | return PhysicalMemory.size().rawValue();
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/sdk/enclave/src/test/java/org/apache/teaclave/javasdk/enclave/testservice/EncryptionService.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.enclave.testservice;
19 |
20 | import org.apache.teaclave.javasdk.common.annotations.EnclaveService;
21 |
22 | import java.security.KeyPair;
23 |
24 | @EnclaveService
25 | public interface EncryptionService {
26 | KeyPair generateKeyPair();
27 | }
28 |
--------------------------------------------------------------------------------
/sdk/enclave/src/test/java/org/apache/teaclave/javasdk/enclave/testservice/IntegerMath.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.enclave.testservice;
19 |
20 | public class IntegerMath extends NumericMath {
21 | @Override
22 | public Number add(Number x, Number y) {
23 | return super.add(x, y);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/sdk/enclave/src/test/java/org/apache/teaclave/javasdk/enclave/testservice/MathService.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.enclave.testservice;
19 |
20 | import org.apache.teaclave.javasdk.common.annotations.EnclaveService;
21 |
22 | import java.security.NoSuchAlgorithmException;
23 | import java.security.SecureRandom;
24 |
25 | @EnclaveService
26 | public interface MathService {
27 | T add(T x, T y);
28 |
29 | T minus(T x, T y);
30 |
31 | T div(T x, T y);
32 |
33 | default int getConstant() {
34 | return 100;
35 | }
36 |
37 | default byte[] getRandomNumber(int size) {
38 | SecureRandom secureRandom = null;
39 | try {
40 | secureRandom = SecureRandom.getInstance("NativePRNG");
41 | } catch (NoSuchAlgorithmException e) {
42 | e.printStackTrace();
43 | }
44 | return secureRandom.generateSeed(size);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/sdk/enclave/src/test/java/org/apache/teaclave/javasdk/enclave/testservice/MemService.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.enclave.testservice;
19 |
20 | import org.apache.teaclave.javasdk.common.annotations.EnclaveService;
21 |
22 | @EnclaveService
23 | public interface MemService {
24 | long getSize();
25 | }
26 |
--------------------------------------------------------------------------------
/sdk/enclave/src/test/java/org/apache/teaclave/javasdk/enclave/testservice/NumericMath.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.enclave.testservice;
19 |
20 | public class NumericMath implements MathService {
21 |
22 | private int counter = 0;
23 |
24 | @Override
25 | public Number add(Number x, Number y) {
26 | synchronized (this) {
27 | counter++;
28 | }
29 | return x.intValue() + y.intValue();
30 | }
31 |
32 | @Override
33 | public Number minus(Number x, Number y) {
34 | synchronized (this) {
35 | counter++;
36 | }
37 | return x.intValue() - y.intValue();
38 | }
39 |
40 | @Override
41 | public Number div(Number x, Number y) {
42 | synchronized (this) {
43 | counter++;
44 | }
45 | return x.intValue() / y.intValue();
46 | }
47 |
48 | public int getCounter() {
49 | synchronized (this) {
50 | return counter;
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/sdk/enclave/src/test/java/org/apache/teaclave/javasdk/enclave/testservice/Point.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.enclave.testservice;
19 |
20 | import java.io.Serializable;
21 |
22 | public class Point implements Serializable {
23 |
24 | private static final long serialVersionUID = -3715916707782706029L;
25 |
26 | public int x;
27 | public int y;
28 |
29 | public Point(int x, int y){
30 | this.x = x;
31 | this.y = y;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/sdk/enclave/src/test/java/org/apache/teaclave/javasdk/enclave/testservice/PointMath.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.enclave.testservice;
19 |
20 | public class PointMath implements MathService{
21 | @Override
22 | public Point add(Point x, Point y) {
23 | return new Point(x.x + y.x, x.y + y.y);
24 | }
25 |
26 | @Override
27 | public Point minus(Point x, Point y) {
28 | return new Point(x.x - y.x, x.y - y.y);
29 | }
30 |
31 | @Override
32 | public Point div(Point x, Point y) {
33 | return new Point(x.x / y.x, x.y / y.y);
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/sdk/enclave/src/test/java/org/apache/teaclave/javasdk/enclave/testservice/SunECOperations.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.enclave.testservice;
19 |
20 | import java.security.KeyPair;
21 | import sun.security.ec.ECKeyPairGenerator;
22 |
23 | public class SunECOperations implements EncryptionService{
24 | @Override
25 | public KeyPair generateKeyPair() {
26 | ECKeyPairGenerator pairGenerator = new ECKeyPairGenerator();
27 | return pairGenerator.generateKeyPair();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/sdk/enclave/src/test/resources/META-INF/services/org.apache.teaclave.javasdk.enclave.testservice.EncryptionService:
--------------------------------------------------------------------------------
1 | org.apache.teaclave.javasdk.enclave.testservice.SunECOperations
--------------------------------------------------------------------------------
/sdk/enclave/src/test/resources/META-INF/services/org.apache.teaclave.javasdk.enclave.testservice.MathService:
--------------------------------------------------------------------------------
1 | org.apache.teaclave.javasdk.enclave.testservice.NumericMath
2 | org.apache.teaclave.javasdk.enclave.testservice.PointMath
3 | org.apache.teaclave.javasdk.enclave.testservice.IntegerMath
4 |
--------------------------------------------------------------------------------
/sdk/enclave/src/test/resources/META-INF/services/org.apache.teaclave.javasdk.enclave.testservice.MemService:
--------------------------------------------------------------------------------
1 | org.apache.teaclave.javasdk.enclave.testservice.EnclaveMem
--------------------------------------------------------------------------------
/sdk/enclave/src/test/resources/native/main_c.c:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | #include
19 | #include
20 | #include "enc_environment.h"
21 | #ifdef MUSL
22 | #include "libmusl_svmenclavesdk.h"
23 | #else
24 | #include "libsvm_enclave_sdk.h"
25 | #endif
26 |
27 | long physical_page_size(){
28 | return 4096;
29 | }
30 |
31 | long physical_page_number(){
32 | return 24576;
33 | }
34 |
35 | long virtual_page_size(){
36 | return 4096;
37 | }
38 |
39 | int main(int argc, char** argv){
40 | graal_isolatethread_t *thread = NULL;
41 | graal_isolate_t *isolate = NULL;
42 | int size = 2;
43 | char** parameters = (char **)malloc(size * sizeof(char*));
44 | parameters[0] = NULL;
45 | parameters[1] = "-Xmx100m";
46 | return create_isolate_with_params(size, parameters, &isolate, &thread);
47 | }
--------------------------------------------------------------------------------
/sdk/host/src/main/java/org/apache/teaclave/javasdk/host/BaseEnclaveServicesRecycler.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.host;
19 |
20 | import java.lang.reflect.InvocationHandler;
21 |
22 | /**
23 | * BaseEnclaveServicesRecycler an empty enclave services recycler for MOCK_IN_JVM enclave.
24 | */
25 | class BaseEnclaveServicesRecycler {
26 | BaseEnclaveServicesRecycler() {
27 | }
28 |
29 | void enqueueProxyHandler(InvocationHandler handler) {
30 | }
31 |
32 | void registerProxyHandler(Object obj, InvocationHandler handler) {
33 | }
34 |
35 | void interruptServiceRecycler() {
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/sdk/host/src/main/java/org/apache/teaclave/javasdk/host/EmbeddedLibOSAttestationReport.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.host;
19 |
20 | /**
21 | * EmbeddedLibOSAttestationReport includes more detail information of remote attestation report
22 | * for lib_os_embedded type enclave.
23 | */
24 | final class EmbeddedLibOSAttestationReport extends SGXAttestationReport {
25 | EmbeddedLibOSAttestationReport(byte[] quote, byte[] mrSigner, byte[] mrEnclave, byte[] userData) {
26 | super(EnclaveType.EMBEDDED_LIB_OS, quote, mrSigner, mrEnclave, userData);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/sdk/host/src/main/java/org/apache/teaclave/javasdk/host/EnclaveDebug.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.host;
19 |
20 | /**
21 | * An enumeration of enclave debug mode.
22 | */
23 | enum EnclaveDebug {
24 | /**
25 | * For MOCK_IN_JVM and MOCK_IN_SVM, there is no real enclave environment.
26 | */
27 | NONE(0),
28 | /**
29 | * TEE_SDK could debug by gdb tool in this mode.
30 | */
31 | DEBUG(1),
32 | /**
33 | * TEE_SDK could not debug by gdb tool in this mode.
34 | */
35 | RELEASE(2);
36 |
37 | private final int value;
38 |
39 | EnclaveDebug(int value) {
40 | this.value = value;
41 | }
42 |
43 | int getValue() {
44 | return value;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/sdk/host/src/main/java/org/apache/teaclave/javasdk/host/EnclaveInfoMXBean.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.host;
19 |
20 | import java.util.List;
21 |
22 | /**
23 | * EnclaveInfoMXBean help query created all existed enclave's detail information.
24 | * Such as existed enclave instance number, every enclave's type info, is debuggable,
25 | * and enclave's epc memory size.
26 | */
27 | public interface EnclaveInfoMXBean {
28 | /**
29 | * get the number of all existed enclaves.
30 | *
31 | * @return number of all existed enclaves.
32 | */
33 | int getEnclaveInstanceNumber();
34 |
35 | /**
36 | * get all existed enclaves' EnclaveInfo details.
37 | *
38 | * @return List all existed enclaves' EnclaveInfo details.
39 | */
40 | List getEnclaveInstancesInfo();
41 | }
42 |
--------------------------------------------------------------------------------
/sdk/host/src/main/java/org/apache/teaclave/javasdk/host/EnclaveSimulate.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.host;
19 |
20 | /**
21 | * An enumeration of enclave simulate mode.
22 | */
23 | enum EnclaveSimulate {
24 | /**
25 | * For MOCK_IN_JVM and MOCK_IN_SVM, there is no real enclave environment.
26 | */
27 | NONE(0),
28 | /**
29 | * TEE_SDK/EMBEDDED_LIB_OS could run in simulate mode without sgx.
30 | */
31 | SIMULATE(1),
32 | /**
33 | * TEE_SDK/EMBEDDED_LIB_OS could run in hardware mode with sgx.
34 | */
35 | HARDWARE(2);
36 |
37 | private final int value;
38 |
39 | EnclaveSimulate(int value) {
40 | this.value = value;
41 | }
42 |
43 | int getValue() {
44 | return value;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/sdk/host/src/main/java/org/apache/teaclave/javasdk/host/RemoteAttestationVerifyResult.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.host;
19 |
20 | final class RemoteAttestationVerifyResult {
21 | private final int status;
22 | private final int versionCheck;
23 | private final int verifyFlag;
24 |
25 | RemoteAttestationVerifyResult(int status, int versionCheck, int verifyFlag) {
26 | this.status = status;
27 | this.versionCheck = versionCheck;
28 | this.verifyFlag = verifyFlag;
29 | }
30 |
31 | int getStatus() {
32 | return this.status;
33 | }
34 |
35 | int getVersionCheck() {
36 | return this.versionCheck;
37 | }
38 |
39 | int getVerifyFlag() {
40 | return this.verifyFlag;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/sdk/host/src/main/java/org/apache/teaclave/javasdk/host/TeeSdkAttestationReport.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.host;
19 |
20 | /**
21 | * TeeSdkAttestationReport parse more details information from a tee sdk type enclave's remote attestation report.
22 | */
23 | final class TeeSdkAttestationReport extends SGXAttestationReport {
24 | TeeSdkAttestationReport(byte[] quote, byte[] mrSigner, byte[] mrEnclave, byte[] userData) {
25 | super(EnclaveType.TEE_SDK, quote, mrSigner, mrEnclave, userData);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/sdk/host/src/main/native/cpp/attestation_verify/sgx/jni/Makefile:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | include $(NATIVE_BASE_DIR)/config/config.mk
19 | include $(NATIVE_BASE_DIR)/config/remote_attestation_verify/sgx/config.mk
20 |
21 | .PHONY: all build clean
22 |
23 | all: build
24 |
25 | build:
26 | $(CC) -g -c -Wno-unused-parameter $(RA_VERIFY_INCDIR) -I$(JAVA_HOME)/lib -I$(JAVA_HOME)/include \
27 | -I$(JAVA_HOME)/include/$(shell uname -s | tr A-Z a-z) -fPIC jni_remote_attestation_verify.c
28 |
29 | $(CC) jni_remote_attestation_verify.o $(RA_VERIFY_LDFLAGS) -fPIC -shared -o $(BIN)/remote_attestation/sgx/jni/lib_jni_sgx_remote_attestation_verify.so
30 |
31 | clean:
32 | rm -rf *.o
33 | rm -rf $(BIN)/remote_attestation/sgx/jni/lib_jni_sgx_remote_attestation_verify.so
--------------------------------------------------------------------------------
/sdk/host/src/main/native/cpp/platform/libos_occlum_enclave/jni/Makefile:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | include $(NATIVE_BASE_DIR)/config/config.mk
19 | include $(NATIVE_BASE_DIR)/config/platform/libos_occlum_enclave/jni/config.mk
20 |
21 | .PHONY: all build clean
22 |
23 | all: build
24 |
25 | build:
26 | $(CC) $(C_FLAGS) -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/$(shell uname -s | tr A-Z a-z) -fPIC jni_occlum_enclave.c
27 | $(CC) jni_occlum_enclave.o $(LINK_FLAGS) -fPIC -shared -o $(BIN)/platform/libos_occlum_enclave/jni/lib_jni_embedded_lib_os_enclave.so
28 |
29 | clean:
30 | rm -rf *.o $(BIN)/platform/libos_occlum_enclave/jni/lib_jni_embedded_lib_os_enclave.so
--------------------------------------------------------------------------------
/sdk/host/src/main/native/cpp/platform/mock_in_svm/jni/Makefile:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | include $(NATIVE_BASE_DIR)/config/config.mk
19 | include $(NATIVE_BASE_DIR)/config/platform/mock_in_svm/jni/config.mk
20 |
21 | .PHONY: all build clean
22 |
23 | all: build
24 |
25 | # compile jni_mock_in_svm.c to $(BIN)/platform/mock_in_svm/jni/lib_jni_mock_svm.so
26 | build:
27 | $(CC) jni_mock_in_svm.c -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/$(shell uname -s | tr A-Z a-z) \
28 | -I$(JAVA_HOME)/lib $(DB_LDFLAGS) -I$(INCLUDE) -fPIC -shared -o $(BIN)/platform/mock_in_svm/jni/lib_jni_mock_svm.so
29 |
30 | # clean lib_jni_mock_svm.so
31 | clean:
32 | rm -rf *.o $(BIN)/platform/mock_in_svm/jni/lib_jni_mock_svm.so
--------------------------------------------------------------------------------
/sdk/host/src/main/native/cpp/platform/tee_sdk_svm/Makefile:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | include $(NATIVE_BASE_DIR)/config/config.mk
19 | include $(NATIVE_BASE_DIR)/config/platform/tee_sdk_svm/jni/config.mk
20 |
21 | .PHONY: all build clean
22 |
23 | all: build
24 |
25 | build: jni.o
26 | $(CC) edge_routines/ocall_svm.o edge_routines/ocall_attestation.o edge_routines/tee_sdk_enclave_u.o \
27 | jni/generate_attestation_report.o jni/jni_tee_sdk_svm.o $(TS_HOST_CFLAGS) $(TS_HOST_LDFLAGS) \
28 | -fPIC -shared -o $(BIN)/platform/tee_sdk_svm/jni/lib_jni_tee_sdk_svm.so
29 |
30 | rm -rf edge_routines/*.o edge_routines/tee_sdk_enclave_u.* jni/*.o
31 |
32 | edge_routines.o:
33 | $(MAKE) -C edge_routines
34 |
35 | jni.o: edge_routines.o
36 | $(MAKE) -C jni
37 |
38 | clean:
39 | $(MAKE) -C edge_routines clean
40 | $(MAKE) -C jni clean
--------------------------------------------------------------------------------
/sdk/host/src/main/native/cpp/platform/tee_sdk_svm/edge_routines/Makefile:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | include $(NATIVE_BASE_DIR)/config/config.mk
19 | include $(NATIVE_BASE_DIR)/config/platform/tee_sdk_svm/jni/config.mk
20 |
21 | .PHONY: all build clean
22 |
23 | all: build
24 |
25 | build:
26 | $(SGX_EDGER8R) $(CONFIG)/platform/tee_sdk_svm/edl/tee_sdk_enclave.edl --untrusted \
27 | --search-path $(TEE_SDK_PATH)/include
28 |
29 | $(CC) -g -c -fPIC $(TS_HOST_INCDIR) $(TS_HOST_CFLAGS) -fPIC ocall_svm.c
30 |
31 | $(CC) -g -c -fPIC $(TS_HOST_INCDIR) $(TS_HOST_CFLAGS) -fPIC ocall_attestation.c
32 |
33 | $(CC) -g -c -fPIC $(TS_HOST_INCDIR) $(TS_HOST_CFLAGS) -fPIC tee_sdk_enclave_u.c
34 |
35 | clean:
36 | rm -rf tee_sdk_enclave_* *.o
--------------------------------------------------------------------------------
/sdk/host/src/main/native/cpp/platform/tee_sdk_svm/edge_routines/ocall_attestation.c:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | #include "ocall_attestation.h"
19 |
20 | // ocall_get_target_info get target info from host.
21 | quote3_error_t ocall_get_target_info(sgx_target_info_t *qe_target_info) {
22 | return sgx_qe_get_target_info(qe_target_info);
23 | }
--------------------------------------------------------------------------------
/sdk/host/src/main/native/cpp/platform/tee_sdk_svm/edge_routines/ocall_attestation.h:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | #ifndef _OCALL_ATTESTATION_H_
19 | #define _OCALL_ATTESTATION_H_
20 |
21 | #include
22 |
23 | #include "sgx_urts.h"
24 | #include "sgx_report.h"
25 | #include "sgx_dcap_ql_wrapper.h"
26 | #include "sgx_pce.h"
27 | #include "sgx_error.h"
28 | #include "sgx_quote_3.h"
29 |
30 | #if defined(__cplusplus)
31 | extern "C"
32 | {
33 | #endif
34 | quote3_error_t ocall_get_target_info(sgx_target_info_t *qe_target_info);
35 | #if defined(__cplusplus)
36 | }
37 | #endif
38 |
39 | #endif /* !_OCALL_ATTESTATION_H_ */
--------------------------------------------------------------------------------
/sdk/host/src/main/native/cpp/platform/tee_sdk_svm/edge_routines/ocall_svm.c:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | #include "ocall_svm.h"
19 |
20 | int ocall_getrlimit(int resource, void *rlim) {
21 | return getrlimit(resource, (struct rlimit *)rlim);
22 | }
23 |
24 | int ocall_malloc(size_t size, void *ptr) {
25 | void* memptr = malloc(size);
26 | if (memptr != NULL) {
27 | *((char **)ptr) = (char *)memptr;
28 | return 0;
29 | }
30 | return -1;
31 | }
--------------------------------------------------------------------------------
/sdk/host/src/main/native/cpp/platform/tee_sdk_svm/edge_routines/ocall_svm.h:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | #ifndef _OCALL_SVM_H_
19 | #define _OCALL_SVM_H_
20 |
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 |
27 | #if defined(__cplusplus)
28 | extern "C"
29 | {
30 | #endif
31 | int ocall_getrlimit(int resource, void *rlim);
32 | int ocall_malloc(size_t size, void *ptr);
33 | #if defined(__cplusplus)
34 | }
35 | #endif
36 |
37 | #endif /* !_OCALL_SVM_H_ */
--------------------------------------------------------------------------------
/sdk/host/src/main/native/cpp/platform/tee_sdk_svm/jni/Makefile:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | include $(NATIVE_BASE_DIR)/config/config.mk
19 | include $(NATIVE_BASE_DIR)/config/platform/tee_sdk_svm/jni/config.mk
20 |
21 | .PHONY: all build clean
22 |
23 | all: build
24 |
25 | build:
26 | $(CC) -g -c -Wno-unused-parameter -fPIC $(TS_HOST_CFLAGS) $(TS_HOST_INCDIR) -I./../edge_routines -I$(JAVA_HOME)/lib -I$(INCLUDE) -I$(JAVA_HOME)/include \
27 | -I$(JAVA_HOME)/include/$(shell uname -s | tr A-Z a-z) jni_tee_sdk_svm.c
28 |
29 | $(CC) -g -c -Wno-unused-parameter -fPIC $(TS_HOST_CFLAGS) $(TS_HOST_INCDIR) -I$(JAVA_HOME)/lib -I$(INCLUDE) -I$(JAVA_HOME)/include \
30 | -I$(JAVA_HOME)/include/$(shell uname -s | tr A-Z a-z) generate_attestation_report.c
31 |
32 | clean:
33 | rm -rf *.o
--------------------------------------------------------------------------------
/sdk/host/src/test/java/org/apache/teaclave/javasdk/host/Service.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.host;
19 |
20 | public interface Service {
21 | void doNothing();
22 |
23 | int add(int a, int b);
24 |
25 | String saySomething(String words);
26 |
27 | void throwException(String code) throws ServiceExceptionTest;
28 | }
29 |
--------------------------------------------------------------------------------
/sdk/host/src/test/java/org/apache/teaclave/javasdk/host/ServiceExceptionTest.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.host;
19 |
20 | public class ServiceExceptionTest extends Exception {
21 | public ServiceExceptionTest(String info) {
22 | super(info);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/sdk/host/src/test/java/org/apache/teaclave/javasdk/host/ServiceImpl.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.host;
19 |
20 | import com.google.auto.service.AutoService;
21 |
22 | @AutoService(Service.class)
23 | public class ServiceImpl implements Service {
24 | @Override
25 | public void doNothing() {
26 | // Do nothing;
27 | }
28 |
29 | @Override
30 | public int add(int a, int b) {
31 | return a + b;
32 | }
33 |
34 | @Override
35 | public String saySomething(String words) {
36 | return words;
37 | }
38 |
39 | @Override
40 | public void throwException(String code) throws ServiceExceptionTest {
41 | throw new ServiceExceptionTest(code);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/sdk/host/src/test/java/org/apache/teaclave/javasdk/host/TestEnclaveFactory.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.host;
19 |
20 | import org.apache.teaclave.javasdk.host.exception.EnclaveCreatingException;
21 | import org.apache.teaclave.javasdk.host.exception.EnclaveDestroyingException;
22 | import org.junit.jupiter.api.Test;
23 |
24 | import static org.junit.jupiter.api.Assertions.*;
25 |
26 | class TestEnclaveFactory {
27 | @Test
28 | void testEnclaveCreate() throws EnclaveCreatingException, EnclaveDestroyingException {
29 | Enclave enclave = EnclaveFactory.create(EnclaveType.MOCK_IN_JVM);
30 | assertTrue(enclave instanceof MockInJvmEnclave);
31 | enclave.destroy();
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/sdk/native/bin/platform/libos_occlum_enclave/jni/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/incubator-teaclave-java-tee-sdk/6dced3005c4ef7585d2f28c82f6dbcab8a5d7357/sdk/native/bin/platform/libos_occlum_enclave/jni/.gitkeep
--------------------------------------------------------------------------------
/sdk/native/bin/platform/libos_occlum_enclave/libos_occlum_enclave_attestation/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/incubator-teaclave-java-tee-sdk/6dced3005c4ef7585d2f28c82f6dbcab8a5d7357/sdk/native/bin/platform/libos_occlum_enclave/libos_occlum_enclave_attestation/.gitkeep
--------------------------------------------------------------------------------
/sdk/native/bin/platform/mock_in_svm/jni/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/incubator-teaclave-java-tee-sdk/6dced3005c4ef7585d2f28c82f6dbcab8a5d7357/sdk/native/bin/platform/mock_in_svm/jni/.gitkeep
--------------------------------------------------------------------------------
/sdk/native/bin/platform/tee_sdk_svm/jni/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/incubator-teaclave-java-tee-sdk/6dced3005c4ef7585d2f28c82f6dbcab8a5d7357/sdk/native/bin/platform/tee_sdk_svm/jni/.gitkeep
--------------------------------------------------------------------------------
/sdk/native/bin/remote_attestation/sgx/jni/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/incubator-teaclave-java-tee-sdk/6dced3005c4ef7585d2f28c82f6dbcab8a5d7357/sdk/native/bin/remote_attestation/sgx/jni/.gitkeep
--------------------------------------------------------------------------------
/sdk/native/config/config.mk:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | # parse BIN path.
19 | BIN = $(NATIVE_BASE_DIR)/bin
20 | # parse CONFIG path.
21 | CONFIG = $(NATIVE_BASE_DIR)/config
22 | # parse INCLUDE path.
23 | INCLUDE = $(NATIVE_BASE_DIR)/include
--------------------------------------------------------------------------------
/sdk/native/config/platform/libos_occlum_enclave/enclave/config.mk:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | CC := /usr/local/occlum/bin/occlum-gcc
19 |
20 | TEE_SDK_PATH = /opt/teesdk/sgxsdk
21 | LIBPATH ?= /opt/occlum/toolchains/dcap_lib/musl
22 | INCPATH ?= /opt/occlum/toolchains/dcap_lib/inc
23 |
--------------------------------------------------------------------------------
/sdk/native/config/platform/libos_occlum_enclave/jni/config.mk:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | CC := gcc
19 | OCCLUM_PREFIX ?= /opt/occlum
20 | SGX_MODE ?= HW
21 |
22 | ifneq ($(SGX_MODE), HW)
23 | URTS_LIBRARY_NAME := sgx_urts_sim
24 | UAE_SERVICE_LIBRARY_NAME := sgx_uae_service_sim
25 | OCCLUM_PAL_LIB := occlum-pal_sim
26 | else
27 | URTS_LIBRARY_NAME := sgx_urts
28 | UAE_SERVICE_LIBRARY_NAME := sgx_uae_service
29 | OCCLUM_PAL_LIB := occlum-pal
30 | endif
31 |
32 | C_FLAGS := -Wl,-z,noexecstack -g -c -Wno-unused-parameter -I$(OCCLUM_PREFIX)/include
33 |
34 | LINK_FLAGS := -lpthread -L$(OCCLUM_PREFIX)/build/lib -L/opt/teesdk/sgxsdk/lib64 -l$(URTS_LIBRARY_NAME) -l$(UAE_SERVICE_LIBRARY_NAME) -lsgx_uprotected_fs
--------------------------------------------------------------------------------
/sdk/native/config/platform/mock_in_svm/jni/config.mk:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | CC = gcc
19 | CXX = g++
20 |
21 | # define mock_in_svm jni.cpp compile option.
22 | DB_LDFLAGS = -Wl,-z,noexecstack -lc -ldl -lpthread -std=c99
--------------------------------------------------------------------------------
/sdk/native/config/platform/tee_sdk_svm/edl/tee_sdk_enclave.lds:
--------------------------------------------------------------------------------
1 | enclave.so
2 | {
3 | global:
4 | g_global_data_sim;
5 | g_global_data;
6 | enclave_entry;
7 | g_peak_heap_used;
8 | g_peak_rsrv_mem_committed;
9 | local:
10 | *;
11 | };
--------------------------------------------------------------------------------
/sdk/native/config/remote_attestation_verify/sgx/config.mk:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | CC = gcc
19 | CXX = g++
20 |
21 | TEE_SDK_PATH = /opt/teesdk/sgxsdk
22 | UBUNTU_OS = $(shell if [ -d "/usr/lib/x86_64-linux-gnu" ]; then echo "yes"; else echo "no"; fi;)
23 | ifeq ("$(UBUNTU_OS)", "yes")
24 | DCAP_LIB_PATH = /usr/lib/x86_64-linux-gnu
25 | else
26 | DCAP_LIB_PATH = /usr/lib64
27 | endif
28 |
29 | RA_VERIFY_INCDIR = -I$(TEE_SDK_PATH)/include
30 | RA_VERIFY_LDFLAGS = -L$(DCAP_LIB_PATH) -lsgx_dcap_quoteverify -lsgx_dcap_ql
31 |
--------------------------------------------------------------------------------
/sdk/native/config/template/Occlum.json:
--------------------------------------------------------------------------------
1 | {
2 | "resource_limits": {
3 | "kernel_space_heap_size": "32MB",
4 | "kernel_space_stack_size": "1MB",
5 | "user_space_size": "1024MB",
6 | "max_num_of_threads": 50
7 | },
8 | "process": {
9 | "default_stack_size": "4MB",
10 | "default_heap_size": "32MB",
11 | "default_mmap_size": "100MB"
12 | },
13 | "entry_points": [
14 | "/usr/lib/dragonwell11/jre/bin"
15 | ],
16 | "env": {
17 | "default": [
18 | "LD_LIBRARY_PATH=/usr/lib/dragonwell11/jre/lib/server:/usr/lib/dragonwell11/jre/lib:/usr/lib/dragonwell11/jre/../lib"
19 | ],
20 | "untrusted": [
21 | "EXAMPLE"
22 | ]
23 | },
24 | "metadata": {
25 | "product_id": 0,
26 | "version_number": 0,
27 | "debuggable": true,
28 | "enable_kss": false,
29 | "family_id": {
30 | "high": "0x0",
31 | "low": "0x0"
32 | },
33 | "ext_prod_id": {
34 | "high": "0x0",
35 | "low": "0x0"
36 | }
37 | },
38 | "mount": [
39 | {
40 | "target": "/",
41 | "type": "unionfs",
42 | "options": {
43 | "layers": [
44 | {
45 | "target": "/",
46 | "type": "sefs",
47 | "source": "./build/mount/__ROOT",
48 | "options": {
49 | "MAC": ""
50 | }
51 | },
52 | {
53 | "target": "/",
54 | "type": "sefs",
55 | "source": "./run/mount/__ROOT"
56 | }
57 | ]
58 | }
59 | },
60 | {
61 | "target": "/host",
62 | "type": "hostfs",
63 | "source": "."
64 | },
65 | {
66 | "target": "/proc",
67 | "type": "procfs"
68 | },
69 | {
70 | "target": "/dev",
71 | "type": "devfs"
72 | }
73 | ]
74 | }
75 |
--------------------------------------------------------------------------------
/sdk/native/config/template/TeeSDK.conf:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 |
19 |
20 | 0
21 | 0
22 | 0x101000
23 | 0x40000000
24 | 50
25 | 1
26 | 0
27 | 0
28 | 0xFFFFFFFF
29 |
--------------------------------------------------------------------------------
/sdk/native/config/template/java_enclave_configure.json:
--------------------------------------------------------------------------------
1 | {
2 | "debuggable": false,
3 | "enclave_type": "TEE_SDK",
4 | "metric_trace_enable": false,
5 | "metric_trace_file_path": "",
6 | "enclave_max_thread": 50,
7 | "enclave_max_epc_memory_size_MB": 1500
8 | }
--------------------------------------------------------------------------------
/sdk/native/include/enc_environment.h:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | typedef struct enc_data_struct{
19 | //char array is used as byte array to store serialized data
20 | char* data;
21 | int data_len;
22 | } enc_data_t;
23 |
24 | typedef struct callback_functions_struct{
25 | /*
26 | * This method is invoked inside java_enclave_invoke method's exception catch
27 | * section, when the execution is aborted by exceptions. The caller side can
28 | * decide what to do with the exception.
29 | * Exception details are passed back with parameters.
30 | */
31 | void (*exception_handler)(char* err_msg, char* stack_trace, char* exception_name);
32 |
33 | char* (*memcpy_char_pointer)(char* src, int len);
34 |
35 | /*
36 | * Points to an available pseudorandom number generating function.
37 | */
38 | int (*get_random_number)(void* data, long size);
39 | } callbacks_t;
40 |
41 | long physical_page_size();
42 | long physical_page_number();
43 | long virtual_page_size();
44 |
--------------------------------------------------------------------------------
/sdk/native/include/enc_exported_symbol.h:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | #ifndef __ENC_EXPORTED_SYMBOL_H
19 | #define __ENC_EXPORTED_SYMBOL_H
20 |
21 | #include "graal_isolate.h"
22 |
23 | #if defined(__cplusplus)
24 | extern "C" {
25 | #endif
26 |
27 | int create_isolate_with_params(int argc, char** parameters, graal_isolate_t** isolate, graal_isolatethread_t** thread);
28 |
29 | int java_loadservice_invoke(graal_isolate_t* thread, enc_data_t* input, enc_data_t* result, callbacks_t* callBacks);
30 |
31 | int java_enclave_invoke(graal_isolate_t* thread, enc_data_t* input, enc_data_t* result, callbacks_t* callBacks);
32 |
33 | int java_unloadservice_invoke(graal_isolate_t* thread, enc_data_t* input, enc_data_t* result, callbacks_t* callBacks);
34 |
35 | #if defined(__cplusplus)
36 | }
37 | #endif
38 | #endif
--------------------------------------------------------------------------------
/sdk/native/script/build_app/create_tee_sdk_configure.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 |
20 | TEE_SDK_CONFIG_FILE_PATH=$1
21 | TEE_SDK_BUILD_WORKSPACE=$2
22 |
23 | # prepare for TeeSDK.conf
24 | cp /opt/javaenclave/config/template/TeeSDK.conf "${TEE_SDK_BUILD_WORKSPACE}"
25 | user_tee_sdk_enclave_config_file=/opt/javaenclave/config/template/java_enclave_configure.json
26 | if [[ -f "${TEE_SDK_CONFIG_FILE_PATH}/java_enclave_configure.json" ]]; then
27 | user_tee_sdk_enclave_config_file=${TEE_SDK_CONFIG_FILE_PATH}/java_enclave_configure.json
28 | fi
29 | max_thread_num=$(< "${user_tee_sdk_enclave_config_file}" jq -r '.enclave_max_thread')
30 | user_space_size=$(< "${user_tee_sdk_enclave_config_file}" jq -r '.enclave_max_epc_memory_size_MB')
31 | user_space_size=$((user_space_size*1024*1024))
32 | user_space_size=$(printf "%x" $user_space_size)
33 | sed -i "s/[0-9]*<\/TCSNum>/${max_thread_num}<\/TCSNum>/g" "${TEE_SDK_BUILD_WORKSPACE}"/TeeSDK.conf
34 | sed -i "s/0x[0-9]*<\/HeapMaxSize>/0x${user_space_size}<\/HeapMaxSize>/g" "${TEE_SDK_BUILD_WORKSPACE}"/TeeSDK.conf
--------------------------------------------------------------------------------
/sdk/native/script/build_enclave_sdk/Makefile:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | .PHONY: all build clean
19 |
20 | all: build
21 |
22 | build:
23 | ifeq ($(TEE_SDK), TRUE)
24 | $(MAKE) -C $(ENCLAVE_BASE_DIR)/src/main/native/cpp/platform/tee_sdk_svm/wrapper
25 | $(MAKE) -C $(ENCLAVE_BASE_DIR)/src/main/native/cpp/platform/tee_sdk_svm/edge_routines
26 | $(MAKE) -C $(ENCLAVE_BASE_DIR)/src/main/native/cpp/platform/tee_sdk_svm/remote_attestation_generate
27 | endif
28 |
29 | ifeq ($(EMBEDDED_LIB_OS), TRUE)
30 | $(MAKE) -C $(ENCLAVE_BASE_DIR)/src/main/native/cpp/platform/libos_occlum_enclave/remote_attestation_generate
31 | endif
32 |
33 | clean:
34 | ifeq ($(TEE_SDK), TRUE)
35 | $(MAKE) -C $(ENCLAVE_BASE_DIR)/src/main/native/cpp/platform/tee_sdk_svm/wrapper clean
36 | $(MAKE) -C $(ENCLAVE_BASE_DIR)/src/main/native/cpp/platform/tee_sdk_svm/edge_routines clean
37 | $(MAKE) -C $(ENCLAVE_BASE_DIR)/src/main/native/cpp/platform/tee_sdk_svm/remote_attestation_generate clean
38 | endif
39 |
40 | ifeq ($(EMBEDDED_LIB_OS), TRUE)
41 | $(MAKE) -C $(ENCLAVE_BASE_DIR)/src/main/native/cpp/platform/libos_occlum_enclave/remote_attestation_generate clean
42 | endif
--------------------------------------------------------------------------------
/sdk/optimizationDetector/src/test/java/org/apache/teaclave/javasdk/tool/optimize/ECallInLoopDetectorTest.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.tool.optimize;
19 |
20 | import org.junit.Test;
21 |
22 | import java.lang.reflect.Method;
23 | import java.util.List;
24 |
25 | import static org.junit.Assert.assertEquals;
26 |
27 | public class ECallInLoopDetectorTest {
28 | @Test
29 | public void testReport() throws NoSuchMethodException {
30 | Method m = LoopCase.class.getDeclaredMethod("foo");
31 | List ret = ECallInLoopDetector.check(m);
32 | assertEquals(1, ret.size());
33 | }
34 |
35 | @Test
36 | public void testNotReport() throws NoSuchMethodException {
37 | Method m = LoopCase.class.getDeclaredMethod("doSomething");
38 | List ret = ECallInLoopDetector.check(m);
39 | assertEquals(0, ret.size());
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/sdk/optimizationDetector/src/test/java/org/apache/teaclave/javasdk/tool/optimize/LoopCase.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.tool.optimize;
19 |
20 | import java.util.ServiceLoader;
21 |
22 | public class LoopCase {
23 | public void foo() {
24 | ServiceLoader exampleLoader = ServiceLoader.load(TestServices.EnclaveServiceExample.class);
25 | TestServices.EnclaveServiceExample example = exampleLoader.findFirst().get();
26 | int max = 100;
27 | int i = 0;
28 | while (i < max) {
29 | example.bar();
30 | i++;
31 | }
32 | }
33 |
34 | public void doSomething(){
35 | ServiceLoader exampleLoader = ServiceLoader.load(TestServices.NormalServiceExample.class);
36 | TestServices.NormalServiceExample example = exampleLoader.findFirst().get();
37 | int max = 100;
38 | int i = 0;
39 | while (i < max) {
40 | example.bar();
41 | i++;
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/sdk/optimizationDetector/src/test/java/org/apache/teaclave/javasdk/tool/optimize/TestServices.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.tool.optimize;
19 |
20 | import org.apache.teaclave.javasdk.common.annotations.EnclaveService;
21 |
22 | public class TestServices {
23 |
24 | @EnclaveService
25 | public interface EnclaveServiceExample{
26 | void bar();
27 | }
28 |
29 | public interface NormalServiceExample{
30 | void bar();
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/test/common/src/main/java/org/apache/teaclave/javasdk/test/common/AESSealedTest.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.test.common;
19 |
20 | import java.io.Serializable;
21 |
22 | public class AESSealedTest implements Serializable, Comparable {
23 | private final String name;
24 | private final int age;
25 | private final int level;
26 |
27 | public AESSealedTest(String name, int age, int level) {
28 | this.name = name;
29 | this.age = age;
30 | this.level = level;
31 | }
32 |
33 | @Override
34 | public int compareTo(AESSealedTest aesSealedTest) {
35 | if (this.name.equals(aesSealedTest.name)
36 | && this.age == aesSealedTest.age
37 | && this.level == aesSealedTest.level) {
38 | return 0;
39 | }
40 | return -1;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/test/common/src/main/java/org/apache/teaclave/javasdk/test/common/AESService.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.test.common;
19 |
20 | import org.apache.teaclave.javasdk.common.annotations.EnclaveService;
21 |
22 | @EnclaveService
23 | public interface AESService {
24 | String aesEncryptAndDecryptPlaintext(String plaintext) throws Exception;
25 | String aesEncryptAndDecryptPlaintextWithPassword(String plaintext, String password, String salt) throws Exception;
26 | Object aesEncryptAndDecryptObject(AESSealedTest obj) throws Exception;
27 | }
28 |
--------------------------------------------------------------------------------
/test/common/src/main/java/org/apache/teaclave/javasdk/test/common/ConcurrencyCalculate.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.test.common;
19 |
20 | import org.apache.teaclave.javasdk.common.annotations.EnclaveService;
21 |
22 | @EnclaveService
23 | public interface ConcurrencyCalculate {
24 | void add(int delta);
25 | long sum();
26 | void addSync(int delta);
27 | long sumSync();
28 | }
29 |
--------------------------------------------------------------------------------
/test/common/src/main/java/org/apache/teaclave/javasdk/test/common/EnclaveException.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.test.common;
19 |
20 | import org.apache.teaclave.javasdk.common.annotations.EnclaveService;
21 |
22 | @EnclaveService
23 | public interface EnclaveException {
24 | void enclaveException(String info) throws JavaEnclaveException;
25 | }
26 |
--------------------------------------------------------------------------------
/test/common/src/main/java/org/apache/teaclave/javasdk/test/common/EnclaveServiceStatistic.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.test.common;
19 |
20 | import org.apache.teaclave.javasdk.common.annotations.EnclaveService;
21 |
22 | @EnclaveService
23 | public interface EnclaveServiceStatistic {
24 | int getEnclaveServiceCount() throws Exception;
25 | }
26 |
--------------------------------------------------------------------------------
/test/common/src/main/java/org/apache/teaclave/javasdk/test/common/JavaEnclaveException.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.test.common;
19 |
20 | public class JavaEnclaveException extends Exception {
21 | public JavaEnclaveException(String info) {
22 | super(info);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/test/common/src/main/java/org/apache/teaclave/javasdk/test/common/MetricTraceService.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.test.common;
19 |
20 | import org.apache.teaclave.javasdk.common.annotations.EnclaveService;
21 |
22 | @EnclaveService
23 | public interface MetricTraceService {
24 | String invertCharacter(String str);
25 | }
26 |
--------------------------------------------------------------------------------
/test/common/src/main/java/org/apache/teaclave/javasdk/test/common/RSAService.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.test.common;
19 |
20 | import org.apache.teaclave.javasdk.common.annotations.EnclaveService;
21 |
22 | @EnclaveService
23 | public interface RSAService {
24 | String encryptAndDecryptWithPlaintext(String plaintext) throws Exception;
25 | }
26 |
--------------------------------------------------------------------------------
/test/common/src/main/java/org/apache/teaclave/javasdk/test/common/ReflectionCallService.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.test.common;
19 |
20 | import org.apache.teaclave.javasdk.common.annotations.EnclaveService;
21 |
22 | @EnclaveService
23 | public interface ReflectionCallService {
24 | int add(int a, int b);
25 | int sub(int a, int b);
26 | }
27 |
--------------------------------------------------------------------------------
/test/common/src/main/java/org/apache/teaclave/javasdk/test/common/SHAService.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.test.common;
19 |
20 | import org.apache.teaclave.javasdk.common.annotations.EnclaveService;
21 |
22 | @EnclaveService
23 | public interface SHAService {
24 | String encryptPlaintext(String plaintext, String SHAType) throws Exception;
25 | }
26 |
--------------------------------------------------------------------------------
/test/common/src/main/java/org/apache/teaclave/javasdk/test/common/SM2Service.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.test.common;
19 |
20 | import org.apache.teaclave.javasdk.common.annotations.EnclaveService;
21 |
22 | @EnclaveService
23 | public interface SM2Service {
24 | String encryptAndDecryptWithPlaintext(String plaintext) throws Exception;
25 | }
26 |
--------------------------------------------------------------------------------
/test/common/src/main/java/org/apache/teaclave/javasdk/test/common/SM3Service.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.test.common;
19 |
20 | import org.apache.teaclave.javasdk.common.annotations.EnclaveService;
21 |
22 | @EnclaveService
23 | public interface SM3Service {
24 | byte[] sm3Service(String plainText) throws Exception;
25 | }
26 |
--------------------------------------------------------------------------------
/test/common/src/main/java/org/apache/teaclave/javasdk/test/common/SM4Service.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.test.common;
19 |
20 | import org.apache.teaclave.javasdk.common.annotations.EnclaveService;
21 |
22 | @EnclaveService
23 | public interface SM4Service {
24 | String sm4Service(String plaintext) throws Exception;
25 | }
26 |
--------------------------------------------------------------------------------
/test/common/src/main/java/org/apache/teaclave/javasdk/test/common/SMSignAndVerify.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.test.common;
19 |
20 | import org.apache.teaclave.javasdk.common.annotations.EnclaveService;
21 |
22 | @EnclaveService
23 | public interface SMSignAndVerify {
24 | Boolean smSignAndVerify(String plaintext) throws Exception;
25 | }
26 |
--------------------------------------------------------------------------------
/test/common/src/main/java/org/apache/teaclave/javasdk/test/common/SayHelloService.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.test.common;
19 |
20 | import org.apache.teaclave.javasdk.common.annotations.EnclaveService;
21 |
22 | @EnclaveService
23 | public interface SayHelloService {
24 | String sayHelloService(String plainText);
25 | String sayHelloWorld();
26 | }
--------------------------------------------------------------------------------
/test/enclave/src/main/java/org/apache/teaclave/javasdk/test/enclave/Calculate.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.test.enclave;
19 |
20 | public class Calculate {
21 | public static int add(int a, int b) {
22 | return a + b;
23 | }
24 |
25 | public static int sub(int a, int b) {
26 | return a - b;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/test/enclave/src/main/java/org/apache/teaclave/javasdk/test/enclave/ConcurrencyCalculateImpl.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.test.enclave;
19 |
20 | import org.apache.teaclave.javasdk.test.common.ConcurrencyCalculate;
21 | import com.google.auto.service.AutoService;
22 |
23 | import java.util.concurrent.atomic.AtomicLong;
24 |
25 | @AutoService(ConcurrencyCalculate.class)
26 | public class ConcurrencyCalculateImpl implements ConcurrencyCalculate {
27 | private final AtomicLong sum = new AtomicLong();
28 | private long sumSync = 0x0;
29 |
30 | @Override
31 | public void add(int delta) {
32 | sum.addAndGet(delta);
33 | }
34 |
35 | @Override
36 | public long sum() {
37 | return sum.get();
38 | }
39 |
40 | @Override
41 | public synchronized void addSync(int delta) {
42 | while(delta > 0x0) {
43 | sumSync++;
44 | delta--;
45 | }
46 | }
47 |
48 | @Override
49 | public synchronized long sumSync() {
50 | return sumSync;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/test/enclave/src/main/java/org/apache/teaclave/javasdk/test/enclave/EnclaveExceptionImpl.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.test.enclave;
19 |
20 | import org.apache.teaclave.javasdk.test.common.EnclaveException;
21 | import org.apache.teaclave.javasdk.test.common.JavaEnclaveException;
22 | import com.google.auto.service.AutoService;
23 |
24 | @AutoService(EnclaveException.class)
25 | public class EnclaveExceptionImpl implements EnclaveException {
26 | @Override
27 | public void enclaveException(String info) throws JavaEnclaveException {
28 | throw new JavaEnclaveException(info);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/test/enclave/src/main/java/org/apache/teaclave/javasdk/test/enclave/EnclaveServiceStatisticImpl.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.test.enclave;
19 |
20 | import org.apache.teaclave.javasdk.test.common.EnclaveServiceStatistic;
21 | import com.google.auto.service.AutoService;
22 |
23 | import java.lang.reflect.Method;
24 |
25 | @AutoService(EnclaveServiceStatistic.class)
26 | public class EnclaveServiceStatisticImpl implements EnclaveServiceStatistic {
27 | @Override
28 | public int getEnclaveServiceCount() throws Exception {
29 | Method getInstance = Class.forName("org.apache.teaclave.javasdk.enclave.framework.EnclaveContext").getMethod("getInstance");
30 | getInstance.setAccessible(true);
31 | Method servicesSize = Class.forName("org.apache.teaclave.javasdk.enclave.framework.EnclaveContext").getMethod("servicesSize");
32 | servicesSize.setAccessible(true);
33 | Object enclaveContext = getInstance.invoke(null);
34 | return (int) servicesSize.invoke(enclaveContext);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/test/enclave/src/main/java/org/apache/teaclave/javasdk/test/enclave/MetricTraceServiceImpl.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.test.enclave;
19 |
20 | import org.apache.teaclave.javasdk.test.common.MetricTraceService;
21 | import com.google.auto.service.AutoService;
22 |
23 | @AutoService(MetricTraceService.class)
24 | public class MetricTraceServiceImpl implements MetricTraceService {
25 | @Override
26 | public String invertCharacter(String str) {
27 | byte[] content = new byte[str.length()];
28 | byte[] initial = str.getBytes();
29 | for (int i = 0x0; i < initial.length; i++) {
30 | content[i] = initial[initial.length - i -1];
31 | }
32 | return new String(content);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/test/enclave/src/main/java/org/apache/teaclave/javasdk/test/enclave/SHAServiceImpl.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.test.enclave;
19 |
20 | import org.apache.teaclave.javasdk.test.common.SHAService;
21 | import com.google.auto.service.AutoService;
22 |
23 | import java.math.BigInteger;
24 | import java.security.MessageDigest;
25 |
26 | @AutoService(SHAService.class)
27 | public class SHAServiceImpl implements SHAService {
28 | @Override
29 | public String encryptPlaintext(String plaintext, String SHAType) throws Exception {
30 | MessageDigest md = MessageDigest.getInstance(SHAType);
31 | byte[] messageDigest = md.digest(plaintext.getBytes());
32 | BigInteger no = new BigInteger(1, messageDigest);
33 | StringBuilder hashText = new StringBuilder(no.toString(16));
34 | while (hashText.length() < 32) {
35 | hashText.insert(0, "0");
36 | }
37 | return hashText.toString();
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/test/enclave/src/main/java/org/apache/teaclave/javasdk/test/enclave/SM3ServiceImpl.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.test.enclave;
19 |
20 | import org.apache.teaclave.javasdk.test.common.SM3Service;
21 | import com.google.auto.service.AutoService;
22 | import org.bouncycastle.crypto.Digest;
23 | import org.bouncycastle.crypto.digests.SM3Digest;
24 |
25 | @AutoService(SM3Service.class)
26 | public class SM3ServiceImpl implements SM3Service {
27 | @Override
28 | public byte[] sm3Service(String plainText) {
29 | byte[] messages = plainText.getBytes();
30 | Digest md = new SM3Digest();
31 | md.update(messages, 0, messages.length);
32 | byte[] digest = new byte[md.getDigestSize()];
33 | md.doFinal(digest, 0);
34 | return digest;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/test/enclave/src/main/java/org/apache/teaclave/javasdk/test/enclave/SayHelloServiceImpl.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.test.enclave;
19 |
20 | import org.apache.teaclave.javasdk.test.common.SayHelloService;
21 |
22 | import com.google.auto.service.AutoService;
23 |
24 | @AutoService(SayHelloService.class)
25 | public class SayHelloServiceImpl implements SayHelloService {
26 | @Override
27 | public String sayHelloService(String plainText) {
28 | return plainText;
29 | }
30 |
31 | @Override
32 | public String sayHelloWorld() {
33 | return "Hello World";
34 | }
35 | }
--------------------------------------------------------------------------------
/test/enclave/src/main/resources/META-INF/native-image/jni-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/test/enclave/src/main/resources/META-INF/native-image/proxy-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/test/enclave/src/main/resources/META-INF/native-image/reflect-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
--------------------------------------------------------------------------------
/test/enclave/src/main/resources/META-INF/native-image/resource-config.json:
--------------------------------------------------------------------------------
1 | {
2 | "resources":{
3 | "includes":[]},
4 | "bundles":[]
5 | }
6 |
--------------------------------------------------------------------------------
/test/enclave/src/main/resources/META-INF/native-image/serialization-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/test/enclave/src/test/java/org/apache/teaclave/javasdk/test/enclave/TestAESServiceImpl.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.test.enclave;
19 |
20 | import org.apache.teaclave.javasdk.test.common.AESSealedTest;
21 | import org.apache.teaclave.javasdk.test.common.AESService;
22 | import org.junit.jupiter.api.Test;
23 |
24 | import static org.junit.jupiter.api.Assertions.assertEquals;
25 |
26 | public class TestAESServiceImpl {
27 | String plaintext = "Hello World!!!";
28 |
29 | @Test
30 | public void testAESServiceImpl() throws Exception {
31 | AESService service = new AESServiceImpl();
32 | String result = service.aesEncryptAndDecryptPlaintext(plaintext);
33 | assertEquals(plaintext, result);
34 | result = service.aesEncryptAndDecryptPlaintextWithPassword(plaintext, "javaenclave", "12345678");
35 | assertEquals(plaintext, result);
36 | AESSealedTest obj = new AESSealedTest("javaenclave", 25, 5);
37 | assertEquals(0, obj.compareTo((AESSealedTest) service.aesEncryptAndDecryptObject(obj)));
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/test/enclave/src/test/java/org/apache/teaclave/javasdk/test/enclave/TestEnclaveException.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.test.enclave;
19 |
20 | import org.apache.teaclave.javasdk.test.common.JavaEnclaveException;
21 |
22 | import org.junit.jupiter.api.*;
23 |
24 | import static org.junit.jupiter.api.Assertions.*;
25 |
26 | public class TestEnclaveException {
27 | @Test
28 | public void testEnclaveException() {
29 | assertThrows(JavaEnclaveException.class, () -> new EnclaveExceptionImpl().enclaveException("Teaclave Java TEE SDK Exception"));
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/test/enclave/src/test/java/org/apache/teaclave/javasdk/test/enclave/TestEnclaveServiceStatisticImpl.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.test.enclave;
19 |
20 | import org.junit.jupiter.api.Test;
21 |
22 | import static org.junit.jupiter.api.Assertions.assertEquals;
23 |
24 | public class TestEnclaveServiceStatisticImpl {
25 | @Test
26 | public void testEnclaveServiceStatisticImpl() throws Exception {
27 | assertEquals(0, new EnclaveServiceStatisticImpl().getEnclaveServiceCount());
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/test/enclave/src/test/java/org/apache/teaclave/javasdk/test/enclave/TestReflectionCallService.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.test.enclave;
19 |
20 | import org.junit.jupiter.api.Test;
21 |
22 | import static org.junit.jupiter.api.Assertions.*;
23 |
24 | public class TestReflectionCallService {
25 |
26 | @Test
27 | public void testReflectionCallService() {
28 | ReflectionCallServiceImpl service = new ReflectionCallServiceImpl();
29 | assertEquals(20, service.add(2, 18));
30 | assertEquals(-20, service.sub(2, 22));
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/test/enclave/src/test/java/org/apache/teaclave/javasdk/test/enclave/TestSayHelloServiceImpl.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.test.enclave;
19 |
20 | import org.junit.jupiter.api.Test;
21 |
22 | import static org.junit.jupiter.api.Assertions.*;
23 |
24 | public class TestSayHelloServiceImpl {
25 |
26 | @Test
27 | public void testSayHelloServiceImpl() {
28 | SayHelloServiceImpl service = new SayHelloServiceImpl();
29 | assertEquals("Hello World", service.sayHelloService("Hello World"));
30 | }
31 | }
--------------------------------------------------------------------------------
/test/run.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 |
20 | # Setting PCCS_URL for SGX Remote Attestation.
21 | # PCCS_URL should be changed according to ECS location.
22 | # PCCS_URL=https://sgx-dcap-server.cn-hongkong.aliyuncs.com/sgx/certification/v3/
23 | echo "PCCS_URL=https://sgx-dcap-server.cn-hongkong.aliyuncs.com/sgx/certification/v3/" > /etc/sgx_default_qcnl.conf
24 | echo "USE_SECURE_CERT=TRUE" >> /etc/sgx_default_qcnl.conf
25 |
26 | # Compile test project.
27 | mvn -Pnative clean package
28 |
29 | # Start Teaclave java sdk test.
30 | OCCLUM_RELEASE_ENCLAVE=true $JAVA_HOME/bin/java -cp host/target/host-0.1.0-jar-with-dependencies.jar:enclave/target/enclave-0.1.0-jar-with-dependencies.jar org.apache.teaclave.javasdk.test.host.TestMain
31 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/Makefile:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | .PHONY: build install clean
19 |
20 | build:
21 | mvn clean -Pnative package
22 |
23 | install:
24 | mvn clean -Pnative install
25 |
26 | clean:
27 | mvn clean
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/bc-java/1.70.build.gradle.patch:
--------------------------------------------------------------------------------
1 | diff --git a/build.gradle b/build.gradle
2 | index 5f2835008..50c1bdbde 100644
3 | --- a/build.gradle
4 | +++ b/build.gradle
5 | @@ -48,6 +48,9 @@ task printProperties {
6 | }
7 | }
8 |
9 | +File callerFilter = file('native-image-agent-caller-filter.json');
10 | +File accessFilter = file('native-image-agent-access-filter.json');
11 | +
12 | subprojects {
13 | apply plugin: 'eclipse'
14 |
15 | @@ -70,7 +73,7 @@ subprojects {
16 | test {
17 | systemProperty 'bc.test.data.home', bcTestDataHome
18 | maxHeapSize = "1536m"
19 | -
20 | + jvmArgs '-agentlib:native-image-agent=config-output-dir=test-configs,caller-filter-file=' + callerFilter.absolutePath + ',access-filter-file=' + accessFilter.absolutePath
21 | filter {
22 | includeTestsMatching "AllTest*"
23 | }
24 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/bc-java/native-image-agent-caller-filter.json:
--------------------------------------------------------------------------------
1 | { "rules": [
2 | {"excludeClasses": "org.gradle.**"},
3 | {"excludeClasses": "junit.**"}
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/make.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 |
20 | mvn clean -Pnative package
21 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/java/org/apache/teaclave/javasdk/thirdpartylibs/bouncycatsle/BCOptions.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.thirdpartylibs.bouncycatsle;
19 |
20 | import com.oracle.svm.core.option.HostedOptionKey;
21 | import org.graalvm.compiler.options.Option;
22 | import org.graalvm.compiler.options.OptionType;
23 |
24 | public class BCOptions {
25 | @Option(help = "When true, register the org.bouncycastle.jce.provider.BouncyCastleProvider.", type = OptionType.User)//
26 | public static final HostedOptionKey RegisterBCProvider = new HostedOptionKey<>(true);
27 | }
28 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/java/org/apache/teaclave/javasdk/thirdpartylibs/bouncycatsle/BouncycastleJarNameFormatException.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.thirdpartylibs.bouncycatsle;
19 |
20 | public class BouncycastleJarNameFormatException extends Exception{
21 | public BouncycastleJarNameFormatException(String msg){
22 | super(msg);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/META-INF/native-image/org.apache.teaclave.javasdk.thirdpartylibs/bouncycastle-native/native-image.properties:
--------------------------------------------------------------------------------
1 | Args=-J--add-exports=jdk.internal.vm.compiler/org.graalvm.compiler.options=ALL-UNNAMED \
2 | -J--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.configure=ALL-UNNAMED \
3 | -J--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.hosted=ALL-UNNAMED \
4 | -J--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.option=ALL-UNNAMED \
5 | -J--add-exports=org.graalvm.sdk/org.graalvm.nativeimage.impl=ALL-UNNAMED
6 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/META-INF/services/org.graalvm.compiler.options.OptionDescriptors:
--------------------------------------------------------------------------------
1 | org.apache.teaclave.javasdk.thirdpartylibs.bouncycatsle.BCOptions_OptionDescriptors
2 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.66/core/jni-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.66/core/predefined-classes-config.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "type":"agent-extracted",
4 | "classes":[
5 | ]
6 | }
7 | ]
8 |
9 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.66/core/proxy-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.66/core/serialization-config.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name":"[B"
4 | },
5 | {
6 | "name":"org.bouncycastle.pqc.crypto.xmss.XMSSNode"
7 | },
8 | {
9 | "name":"java.lang.Integer"
10 | },
11 | {
12 | "name":"org.bouncycastle.pqc.crypto.xmss.BDSStateMap"
13 | },
14 | {
15 | "name":"java.util.Stack"
16 | },
17 | {
18 | "name":"java.util.ArrayList"
19 | },
20 | {
21 | "name":"java.util.HashSet"
22 | },
23 | {
24 | "name":"[Ljava.lang.Object;"
25 | },
26 | {
27 | "name":"java.util.Vector"
28 | },
29 | {
30 | "name":"java.util.TreeMap"
31 | },
32 | {
33 | "name":"org.bouncycastle.pqc.crypto.xmss.BDS"
34 | },
35 | {
36 | "name":"org.bouncycastle.pqc.crypto.xmss.BDSTreeHash"
37 | },
38 | {
39 | "name":"java.lang.Number"
40 | },
41 | {
42 | "name":"java.util.LinkedList"
43 | },
44 | {
45 | "name":"java.util.LinkedHashSet"
46 | }
47 | ]
48 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.66/mail/jni-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.66/mail/predefined-classes-config.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "type":"agent-extracted",
4 | "classes":[
5 | ]
6 | }
7 | ]
8 |
9 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.66/mail/proxy-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.66/mail/serialization-config.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name":"java.util.HashSet"
4 | },
5 | {
6 | "name":"java.util.LinkedHashSet"
7 | }
8 | ]
9 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.66/pg/jni-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.66/pg/predefined-classes-config.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "type":"agent-extracted",
4 | "classes":[
5 | ]
6 | }
7 | ]
8 |
9 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.66/pg/proxy-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.66/pg/serialization-config.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name":"java.util.HashSet"
4 | },
5 | {
6 | "name":"java.util.LinkedHashSet"
7 | }
8 | ]
9 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.66/pkix/jni-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.66/pkix/predefined-classes-config.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "type":"agent-extracted",
4 | "classes":[
5 | ]
6 | }
7 | ]
8 |
9 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.66/pkix/proxy-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.66/pkix/serialization-config.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name":"java.lang.Throwable"
4 | },
5 | {
6 | "name":"org.bouncycastle.cert.X509CertificateHolder"
7 | },
8 | {
9 | "name":"[Ljava.lang.StackTraceElement;"
10 | },
11 | {
12 | "name":"[B"
13 | },
14 | {
15 | "name":"java.security.cert.CertPath$CertPathRep"
16 | },
17 | {
18 | "name":"java.security.cert.CertPath"
19 | },
20 | {
21 | "name":"org.bouncycastle.cert.X509CRLHolder"
22 | },
23 | {
24 | "name":"java.lang.Exception"
25 | },
26 | {
27 | "name":"java.security.InvalidAlgorithmParameterException"
28 | },
29 | {
30 | "name":"java.util.HashSet"
31 | },
32 | {
33 | "name":"java.security.GeneralSecurityException"
34 | },
35 | {
36 | "name":"java.util.Collections$EmptyList"
37 | },
38 | {
39 | "name":"java.lang.StackTraceElement"
40 | },
41 | {
42 | "name":"java.lang.String"
43 | },
44 | {
45 | "name":"org.bouncycastle.cert.X509AttributeCertificateHolder"
46 | },
47 | {
48 | "name":"java.util.LinkedHashSet"
49 | }
50 | ]
51 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.66/prov/jni-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.66/prov/predefined-classes-config.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "type":"agent-extracted",
4 | "classes":[
5 | ]
6 | }
7 | ]
8 |
9 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.66/prov/proxy-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.66/tls/jni-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.66/tls/predefined-classes-config.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "type":"agent-extracted",
4 | "classes":[
5 | ]
6 | }
7 | ]
8 |
9 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.66/tls/proxy-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.66/tls/serialization-config.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name":"java.util.HashSet"
4 | },
5 | {
6 | "name":"java.util.LinkedHashSet"
7 | }
8 | ]
9 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.66/util/jni-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.66/util/predefined-classes-config.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "type":"agent-extracted",
4 | "classes":[
5 | ]
6 | }
7 | ]
8 |
9 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.66/util/proxy-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.66/util/resource-config.json:
--------------------------------------------------------------------------------
1 | {
2 | "resources":{
3 | "includes":[
4 | {"pattern":"\\Qorg/bouncycastle/asn1/icao/test/masterlist-content.data\\E"},
5 | {"pattern":"\\Qorg/slf4j/impl/StaticLoggerBinder.class\\E"}
6 | ]},
7 | "bundles":[]
8 | }
9 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.66/util/serialization-config.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name":"java.util.HashSet"
4 | },
5 | {
6 | "name":"java.util.LinkedHashSet"
7 | }
8 | ]
9 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.70/core/jni-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.70/core/predefined-classes-config.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "type":"agent-extracted",
4 | "classes":[
5 | ]
6 | }
7 | ]
8 |
9 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.70/core/proxy-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.70/core/serialization-config.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name":"[B"
4 | },
5 | {
6 | "name":"org.bouncycastle.pqc.crypto.xmss.XMSSNode"
7 | },
8 | {
9 | "name":"java.lang.Integer"
10 | },
11 | {
12 | "name":"org.bouncycastle.pqc.crypto.xmss.BDSStateMap"
13 | },
14 | {
15 | "name":"java.util.Stack"
16 | },
17 | {
18 | "name":"java.util.ArrayList"
19 | },
20 | {
21 | "name":"java.util.HashSet"
22 | },
23 | {
24 | "name":"[Ljava.lang.Object;"
25 | },
26 | {
27 | "name":"java.util.Vector"
28 | },
29 | {
30 | "name":"java.util.TreeMap"
31 | },
32 | {
33 | "name":"org.bouncycastle.pqc.crypto.xmss.BDS"
34 | },
35 | {
36 | "name":"org.bouncycastle.pqc.crypto.xmss.BDSTreeHash"
37 | },
38 | {
39 | "name":"java.lang.Number"
40 | },
41 | {
42 | "name":"java.util.LinkedList"
43 | },
44 | {
45 | "name":"java.util.LinkedHashSet"
46 | }
47 | ]
48 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.70/mail/jni-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.70/mail/predefined-classes-config.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "type":"agent-extracted",
4 | "classes":[
5 | ]
6 | }
7 | ]
8 |
9 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.70/mail/proxy-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.70/mail/serialization-config.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name":"java.util.HashSet"
4 | },
5 | {
6 | "name":"java.util.LinkedHashSet"
7 | }
8 | ]
9 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.70/pg/jni-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.70/pg/predefined-classes-config.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "type":"agent-extracted",
4 | "classes":[
5 | ]
6 | }
7 | ]
8 |
9 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.70/pg/proxy-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.70/pg/serialization-config.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name":"java.util.HashSet"
4 | },
5 | {
6 | "name":"java.util.LinkedHashSet"
7 | }
8 | ]
9 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.70/pkix/jni-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.70/pkix/predefined-classes-config.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "type":"agent-extracted",
4 | "classes":[
5 | ]
6 | }
7 | ]
8 |
9 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.70/pkix/proxy-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.70/pkix/serialization-config.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name":"java.util.HashSet"
4 | },
5 | {
6 | "name":"org.bouncycastle.cert.X509CertificateHolder"
7 | },
8 | {
9 | "name":"[B"
10 | },
11 | {
12 | "name":"java.security.cert.CertPath$CertPathRep"
13 | },
14 | {
15 | "name":"java.security.cert.CertPath"
16 | },
17 | {
18 | "name":"java.lang.String"
19 | },
20 | {
21 | "name":"org.bouncycastle.cert.X509AttributeCertificateHolder"
22 | },
23 | {
24 | "name":"org.bouncycastle.cert.X509CRLHolder"
25 | },
26 | {
27 | "name":"java.util.LinkedHashSet"
28 | }
29 | ]
30 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.70/prov/jni-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.70/prov/predefined-classes-config.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "type":"agent-extracted",
4 | "classes":[
5 | ]
6 | }
7 | ]
8 |
9 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.70/prov/proxy-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.70/tls/jni-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.70/tls/predefined-classes-config.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "type":"agent-extracted",
4 | "classes":[
5 | ]
6 | }
7 | ]
8 |
9 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.70/tls/proxy-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.70/tls/serialization-config.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name":"java.util.HashSet"
4 | },
5 | {
6 | "name":"java.util.LinkedHashSet"
7 | }
8 | ]
9 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.70/util/jni-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.70/util/predefined-classes-config.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "type":"agent-extracted",
4 | "classes":[
5 | ]
6 | }
7 | ]
8 |
9 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.70/util/proxy-config.json:
--------------------------------------------------------------------------------
1 | [
2 | ]
3 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.70/util/resource-config.json:
--------------------------------------------------------------------------------
1 | {
2 | "resources":{
3 | "includes":[
4 | {"pattern":"\\Qorg/bouncycastle/asn1/icao/test/masterlist-content.data\\E"},
5 | {"pattern":"\\Qorg/slf4j/impl/StaticLoggerBinder.class\\E"}
6 | ]},
7 | "bundles":[]
8 | }
9 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/main/resources/configs/1.70/util/serialization-config.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name":"java.util.HashSet"
4 | },
5 | {
6 | "name":"java.util.LinkedHashSet"
7 | }
8 | ]
9 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/test/java/org/apache/teaclave/javasdk/thirdpartylibs/bouncycatsle/BcService.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.thirdpartylibs.bouncycatsle;
19 |
20 | public interface BcService {
21 | String sm2Service(String plainText);
22 |
23 | String sm3Service(String plainText);
24 |
25 | String digestService(String type, String plainText);
26 |
27 | String rsaService(String plainText);
28 | }
29 |
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/test/java/org/apache/teaclave/javasdk/thirdpartylibs/bouncycatsle/Sm2Service.java:
--------------------------------------------------------------------------------
1 | // Licensed to the Apache Software Foundation (ASF) under one
2 | // or more contributor license agreements. See the NOTICE file
3 | // distributed with this work for additional information
4 | // regarding copyright ownership. The ASF licenses this file
5 | // to you under the Apache License, Version 2.0 (the
6 | // "License"); you may not use this file except in compliance
7 | // with the License. You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing,
12 | // software distributed under the License is distributed on an
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | // KIND, either express or implied. See the License for the
15 | // specific language governing permissions and limitations
16 | // under the License.
17 |
18 | package org.apache.teaclave.javasdk.thirdpartylibs.bouncycatsle;
19 |
20 | public interface Sm2Service {
21 | String getPublicKey();
22 | String getPrivateKey();
23 | String encode(String input, String pubKey);
24 | byte[] decoder(String input, String prvKey);
25 | String sign(String plainText, String prvKey);
26 | boolean verify(String plainText, String signatureValue, String pubKey);
27 | boolean certVerify(String certStr, String plaintext, String signValueStr);
28 | }
--------------------------------------------------------------------------------
/third-party-libs/bouncycastle-native/src/test/resources/META-INF/services/org.apache.teaclave.javasdk.thirdpartylibs.bouncycatsle.BcService:
--------------------------------------------------------------------------------
1 | org.apache.teaclave.javasdk.thirdpartylibs.bouncycatsle.BcServiceImpl
--------------------------------------------------------------------------------
/tools/cicd/anolis-8.6/dockerfile_release:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | FROM java_enclave_build_anolis8.6:v0.1.0 as java_enclave_release_anolis_8_6
19 |
20 | LABEL maintainer="Junshao Wang"
21 |
22 | # Install Teaclave Java TEE SDK
23 | WORKDIR /opt
24 | ADD ["javaenclave.tar.gz", "."]
25 |
--------------------------------------------------------------------------------
/tools/cicd/anolis-8.6/graalvm/build_graalvm_jdk.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 |
20 | SHELL_FOLDER=$(cd "$(dirname "$0")";pwd)
21 | pushd "${SHELL_FOLDER}"
22 |
23 | dnf clean all && rm -r /var/cache/dnf && dnf --enablerepo=PowerTools install -y wget
24 |
25 | # Download GraalVM_22.2.0 JDK from github
26 | wget -c -q https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.2.0/graalvm-ce-java11-linux-amd64-22.2.0.tar.gz -O - | tar -xz
27 |
28 | # cd graalvm-ce-java11-22.2.0 and gu install native-image
29 | pushd graalvm-ce-java11-22.2.0 && ./bin/gu install native-image && popd
30 |
31 | # archive graalvm-ce-java11-22.2.0 which installed native-image
32 | tar -zcvf graalvm-ce-java11-22.2.0.tar.gz graalvm-ce-java11-22.2.0 && rm -rf graalvm-ce-java11-22.2.0
33 |
34 | popd
--------------------------------------------------------------------------------
/tools/cicd/anolis-8.6/graalvm/make.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 |
20 | SHELL_FOLDER=$(cd "$(dirname "$0")";pwd)
21 | pushd "${SHELL_FOLDER}"
22 |
23 | # download graalvm_22.2.0 and install native-image in docker anolis8.6
24 | # shellcheck disable=SC2046
25 | docker run -i --rm --network host -v `pwd`:`pwd` openanolis/anolisos:8.6-x86_64 /bin/bash "${SHELL_FOLDER}"/build_graalvm_jdk.sh
26 |
27 | popd
--------------------------------------------------------------------------------
/tools/cicd/anolis-8.6/teesdk/build_tee_sdk.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 |
20 | SHELL_FOLDER=$(cd "$(dirname "$0")";pwd)
21 | pushd "${SHELL_FOLDER}"
22 |
23 | rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
24 | dnf clean all && rm -r /var/cache/dnf
25 | dnf group install 'Development Tools'
26 | dnf --enablerepo=PowerTools install -y ocaml ocaml-ocamlbuild redhat-rpm-config openssl-devel wget rpm-build git cmake perl python2 gcc-c++
27 | alternatives --set python /usr/bin/python2
28 |
29 | rm -rf linux-sgx
30 |
31 | git clone https://github.com/intel/linux-sgx.git
32 |
33 | pushd linux-sgx && git checkout stdc_ex_1.0
34 |
35 | make preparation && cp external/toolset/centos8/* /usr/local/bin && which ar as ld objcopy objdump ranlib
36 |
37 | make sdk && make sdk_install_pkg && popd
38 |
39 | cp linux-sgx/linux/installer/bin/sgx_linux_x64_sdk_*.bin ./
40 |
41 | rm -rf linux-sgx
42 |
43 | popd
--------------------------------------------------------------------------------
/tools/cicd/anolis-8.6/teesdk/make.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 |
20 | SHELL_FOLDER=$(cd "$(dirname "$0")";pwd)
21 | pushd "${SHELL_FOLDER}"
22 |
23 | # download intel sgx sdk and build it in docker anolis8.6
24 | docker run -i --rm --network host -v `pwd`:`pwd` openanolis/anolisos:8.6-x86_64 /bin/bash "${SHELL_FOLDER}"/build_tee_sdk.sh
25 |
26 | popd
--------------------------------------------------------------------------------
/tools/cicd/jenkinsfile:
--------------------------------------------------------------------------------
1 | pipeline {
2 | agent {
3 | node {
4 | label 'javaenclave_ci_server'
5 | customWorkspace '/home/ci/jenkins/javaenclave'
6 | }
7 | }
8 | stages {
9 | stage('Test and Build Teaclave Java TEE SDK') {
10 | steps {
11 | echo 'Build Teaclave Java TEE SDK:'
12 | sh "./tools/cicd/make.sh"
13 | }
14 | post {
15 | success {
16 | jacoco (
17 | execPattern: 'sdk/**/target/jacoco.exec',
18 | classPattern: 'sdk/**/target/classes',
19 | sourcePattern: 'sdk/**/src/main/java',
20 | sourceInclusionPattern: 'org/apache/teaclave/javasdk/**/*.java,org/apache/teaclave/javasdk/**/**/*.java',
21 | )
22 | }
23 | }
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/tools/cicd/ubuntu-18.04/dockerfile_release:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | FROM java_enclave_build_ubuntu18.04:v0.1.0 as java_enclave_release_ubuntu18_04
19 |
20 | LABEL maintainer="Junshao Wang"
21 |
22 | # Install Teaclave Java TEE SDK
23 | WORKDIR /opt
24 | ADD ["javaenclave.tar.gz", "."]
25 |
--------------------------------------------------------------------------------
/tools/cicd/ubuntu-18.04/graalvm/build_graalvm_jdk.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 |
20 | SHELL_FOLDER=$(cd "$(dirname "$0")";pwd)
21 | pushd "${SHELL_FOLDER}"
22 |
23 | apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y wget
24 |
25 | # Download GraalVM_22.2.0 JDK from github
26 | wget -c -q https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.2.0/graalvm-ce-java11-linux-amd64-22.2.0.tar.gz -O - | tar -xz
27 |
28 | # cd graalvm-ce-java11-22.2.0 and gu install native-image
29 | pushd graalvm-ce-java11-22.2.0 && ./bin/gu install native-image && popd
30 |
31 | # archive graalvm-ce-java11-22.2.0 which installed native-image
32 | tar -zcvf graalvm-ce-java11-22.2.0.tar.gz graalvm-ce-java11-22.2.0 && rm -rf graalvm-ce-java11-22.2.0
33 |
34 | popd
--------------------------------------------------------------------------------
/tools/cicd/ubuntu-18.04/graalvm/make.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 |
20 | SHELL_FOLDER=$(cd "$(dirname "$0")";pwd)
21 | pushd "${SHELL_FOLDER}"
22 |
23 | # download graalvm_22.2.0 and install native-image in docker ubuntu:18.04
24 | # shellcheck disable=SC2046
25 | docker run -i --rm --network host -v `pwd`:`pwd` ubuntu:18.04 /bin/bash "${SHELL_FOLDER}"/build_graalvm_jdk.sh
26 |
27 | popd
--------------------------------------------------------------------------------
/tools/cicd/ubuntu-18.04/teesdk/build_tee_sdk.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 |
20 | SHELL_FOLDER=$(cd "$(dirname "$0")";pwd)
21 | pushd "${SHELL_FOLDER}"
22 |
23 | apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential ocaml ocamlbuild automake autoconf libtool wget python libssl-dev git cmake perl unzip
24 |
25 | rm -rf linux-sgx
26 |
27 | git clone https://github.com/intel/linux-sgx.git
28 |
29 | pushd linux-sgx && git checkout stdc_ex_1.0
30 |
31 | make preparation && cp external/toolset/ubuntu18.04/* /usr/local/bin && which ar as ld objcopy objdump ranlib
32 |
33 | make sdk && make sdk_install_pkg && popd
34 |
35 | cp linux-sgx/linux/installer/bin/sgx_linux_x64_sdk_*.bin ./
36 |
37 | rm -rf linux-sgx
38 |
39 | popd
--------------------------------------------------------------------------------
/tools/cicd/ubuntu-18.04/teesdk/make.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 |
20 | SHELL_FOLDER=$(cd "$(dirname "$0")";pwd)
21 | pushd "${SHELL_FOLDER}"
22 |
23 | # download intel sgx sdk and build it in docker ubuntu18.04
24 | docker run -i --rm --network host -v `pwd`:`pwd` ubuntu:18.04 /bin/bash "${SHELL_FOLDER}"/build_tee_sdk.sh
25 |
26 | popd
--------------------------------------------------------------------------------