Page MenuHomePhabricator

No OneTemporary

diff --git a/native/android/app/src/cpp/PlatformSpecificTools.cpp b/native/android/app/src/cpp/PlatformSpecificTools.cpp
index 6dbbdd9c5..d3f1dc58c 100644
--- a/native/android/app/src/cpp/PlatformSpecificTools.cpp
+++ b/native/android/app/src/cpp/PlatformSpecificTools.cpp
@@ -1,36 +1,40 @@
#include "PlatformSpecificTools.h"
#include "Logger.h"
#include <fbjni/fbjni.h>
using namespace facebook::jni;
class PlatformSpecificToolsJavaClass
: public JavaClass<PlatformSpecificToolsJavaClass> {
public:
static auto constexpr kJavaDescriptor =
"Lapp/comm/android/fbjni/PlatformSpecificTools;";
static comm::crypto::OlmBuffer generateSecureRandomBytes(size_t size) {
static const auto cls = javaClassStatic();
static auto method =
cls->getStaticMethod<JArrayByte(int)>("generateSecureRandomBytes");
auto methodResult = method(cls, (int)size);
comm::crypto::OlmBuffer result(size);
std::vector<jbyte> bytes(size);
methodResult->getRegion(0, size, bytes.data());
for (size_t i = 0; i < size; ++i) {
result[i] = bytes[i];
}
return result;
}
};
namespace comm {
void PlatformSpecificTools::generateSecureRandomBytes(
crypto::OlmBuffer &buffer,
size_t size) {
buffer = PlatformSpecificToolsJavaClass::generateSecureRandomBytes(size);
}
+std::string PlatformSpecificTools::getDeviceOS() {
+ return std::string{"android"};
+}
+
} // namespace comm
diff --git a/native/cpp/CommonCpp/Tools/PlatformSpecificTools.h b/native/cpp/CommonCpp/Tools/PlatformSpecificTools.h
index addeb63c5..83d3b8567 100644
--- a/native/cpp/CommonCpp/Tools/PlatformSpecificTools.h
+++ b/native/cpp/CommonCpp/Tools/PlatformSpecificTools.h
@@ -1,12 +1,13 @@
#pragma once
#include "../CryptoTools/Tools.h"
namespace comm {
class PlatformSpecificTools {
public:
static void generateSecureRandomBytes(crypto::OlmBuffer &buffer, size_t size);
+ static std::string getDeviceOS();
};
} // namespace comm
diff --git a/native/ios/Comm/PlatformSpecificTools.mm b/native/ios/Comm/PlatformSpecificTools.mm
index 9550743bd..58b11cd1f 100644
--- a/native/ios/Comm/PlatformSpecificTools.mm
+++ b/native/ios/Comm/PlatformSpecificTools.mm
@@ -1,22 +1,26 @@
#import "PlatformSpecificTools.h"
#import <Foundation/Foundation.h>
#import <string>
namespace comm {
void PlatformSpecificTools::generateSecureRandomBytes(
crypto::OlmBuffer &buffer,
size_t size) {
uint8_t randomBytes[size];
const int status = SecRandomCopyBytes(kSecRandomDefault, size, randomBytes);
if (status == errSecSuccess) {
buffer = crypto::OlmBuffer(randomBytes, randomBytes + size);
} else {
throw std::runtime_error(
"SecRandomCopyBytes failed for some reason, error code: " +
std::to_string(status));
}
}
+std::string PlatformSpecificTools::getDeviceOS() {
+ return std::string{"ios"};
+}
+
};

File Metadata

Mime Type
text/x-diff
Expires
Mon, Dec 23, 8:48 AM (15 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2690663
Default Alt Text
(2 KB)

Event Timeline