JNIDACProvider.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. *
  3. * Copyright (c) 2023 Project CHIP Authors
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * 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, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. #pragma once
  18. #include "lib/support/logging/CHIPLogging.h"
  19. #include <credentials/DeviceAttestationCredsProvider.h>
  20. #include <jni.h>
  21. class JNIDACProvider : public chip::Credentials::DeviceAttestationCredentialsProvider
  22. {
  23. public:
  24. JNIDACProvider(jobject provider);
  25. CHIP_ERROR GetCertificationDeclaration(chip::MutableByteSpan & out_cd_buffer) override;
  26. CHIP_ERROR GetFirmwareInformation(chip::MutableByteSpan & out_firmware_info_buffer) override;
  27. CHIP_ERROR GetDeviceAttestationCert(chip::MutableByteSpan & out_dac_buffer) override;
  28. CHIP_ERROR GetProductAttestationIntermediateCert(chip::MutableByteSpan & out_pai_buffer) override;
  29. CHIP_ERROR SignWithDeviceAttestationKey(const chip::ByteSpan & digest_to_sign,
  30. chip::MutableByteSpan & out_signature_buffer) override;
  31. private:
  32. CHIP_ERROR GetJavaByteByMethod(jmethodID method, chip::MutableByteSpan & out_buffer);
  33. jobject mJNIDACProviderObject = nullptr;
  34. jmethodID mGetCertificationDeclarationMethod = nullptr;
  35. jmethodID mGetFirmwareInformationMethod = nullptr;
  36. jmethodID mGetDeviceAttestationCertMethod = nullptr;
  37. jmethodID mGetProductAttestationIntermediateCertMethod = nullptr;
  38. jmethodID mGetDeviceAttestationCertPrivateKeyMethod = nullptr;
  39. jmethodID mGetDeviceAttestationCertPublicKeyKeyMethod = nullptr;
  40. };