Skip to content

Commit 2587014

Browse files
committed
chore: clang format
1 parent 6298da5 commit 2587014

File tree

5 files changed

+27
-35
lines changed

5 files changed

+27
-35
lines changed

packages/react-native-quick-crypto/cpp/ed25519/HybridEdKeyPair.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
#include <NitroModules/ArrayBuffer.hpp>
12
#include <memory>
2-
#include <string>
33
#include <openssl/evp.h>
4-
#include <NitroModules/ArrayBuffer.hpp>
4+
#include <string>
55

66
#include "HybridEdKeyPair.hpp"
77

@@ -13,15 +13,13 @@ std::shared_ptr<ArrayBuffer> HybridEdKeyPair::diffieHellman(const std::shared_pt
1313
using EVP_PKEY_CTX_ptr = std::unique_ptr<EVP_PKEY_CTX, decltype(&EVP_PKEY_CTX_free)>;
1414

1515
// 1. Create EVP_PKEY for private key (our key)
16-
EVP_PKEY_ptr pkey_priv(EVP_PKEY_new_raw_private_key(EVP_PKEY_X25519, NULL, privateKey->data(), privateKey->size()),
17-
EVP_PKEY_free);
16+
EVP_PKEY_ptr pkey_priv(EVP_PKEY_new_raw_private_key(EVP_PKEY_X25519, NULL, privateKey->data(), privateKey->size()), EVP_PKEY_free);
1817
if (!pkey_priv) {
1918
throw std::runtime_error("Failed to create private key: " + getOpenSSLError());
2019
}
2120

2221
// 2. Create EVP_PKEY for public key (peer's key)
23-
EVP_PKEY_ptr pkey_pub(EVP_PKEY_new_raw_public_key(EVP_PKEY_X25519, NULL, publicKey->data(), publicKey->size()),
24-
EVP_PKEY_free);
22+
EVP_PKEY_ptr pkey_pub(EVP_PKEY_new_raw_public_key(EVP_PKEY_X25519, NULL, publicKey->data(), publicKey->size()), EVP_PKEY_free);
2523
if (!pkey_pub) {
2624
throw std::runtime_error("Failed to create public key: " + getOpenSSLError());
2725
}

packages/react-native-quick-crypto/cpp/ed25519/HybridEdKeyPair.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ class HybridEdKeyPair : public HybridEdKeyPairSpec {
1616

1717
public:
1818
// Methods
19-
std::shared_ptr<ArrayBuffer> diffieHellman(const std::shared_ptr<ArrayBuffer>& privateKey,
19+
std::shared_ptr<ArrayBuffer> diffieHellman(const std::shared_ptr<ArrayBuffer>& privateKey,
2020
const std::shared_ptr<ArrayBuffer>& publicKey) override;
21-
21+
2222
std::shared_ptr<Promise<void>> generateKeyPair(double publicFormat, double publicType, double privateFormat, double privateType,
2323
const std::optional<std::string>& cipher,
2424
const std::optional<std::shared_ptr<ArrayBuffer>>& passphrase) override;

packages/react-native-quick-crypto/cpp/keys/HybridKeyObjectHandle.cpp

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44

55
namespace margelo::nitro::crypto {
66

7-
std::shared_ptr<ArrayBuffer> HybridKeyObjectHandle::exportKey(
8-
std::optional<KFormatType> format,
9-
std::optional<KeyEncoding> type,
10-
const std::optional<std::string>& cipher,
11-
const std::optional<std::shared_ptr<ArrayBuffer>>& passphrase) {
7+
std::shared_ptr<ArrayBuffer> HybridKeyObjectHandle::exportKey(std::optional<KFormatType> format, std::optional<KeyEncoding> type,
8+
const std::optional<std::string>& cipher,
9+
const std::optional<std::shared_ptr<ArrayBuffer>>& passphrase) {
1210
throw std::runtime_error("Not yet implemented");
1311
}
1412

@@ -20,24 +18,17 @@ CFRGKeyPairType HybridKeyObjectHandle::getAsymmetricKeyType() {
2018
throw std::runtime_error("Not yet implemented");
2119
}
2220

23-
bool HybridKeyObjectHandle::init(
24-
KeyType keyType,
25-
const std::variant<std::string, std::shared_ptr<ArrayBuffer>>& key,
26-
std::optional<KFormatType> format,
27-
std::optional<KeyEncoding> type,
28-
const std::optional<std::shared_ptr<ArrayBuffer>>& passphrase) {
21+
bool HybridKeyObjectHandle::init(KeyType keyType, const std::variant<std::string, std::shared_ptr<ArrayBuffer>>& key,
22+
std::optional<KFormatType> format, std::optional<KeyEncoding> type,
23+
const std::optional<std::shared_ptr<ArrayBuffer>>& passphrase) {
2924
throw std::runtime_error("Not yet implemented");
3025
}
3126

32-
bool HybridKeyObjectHandle::initECRaw(
33-
const std::string& curveName,
34-
const std::shared_ptr<ArrayBuffer>& keyData) {
27+
bool HybridKeyObjectHandle::initECRaw(const std::string& curveName, const std::shared_ptr<ArrayBuffer>& keyData) {
3528
throw std::runtime_error("Not yet implemented");
3629
}
3730

38-
std::optional<KeyType> HybridKeyObjectHandle::initJwk(
39-
const JWK& keyData,
40-
std::optional<NamedCurve> namedCurve) {
31+
std::optional<KeyType> HybridKeyObjectHandle::initJwk(const JWK& keyData, std::optional<NamedCurve> namedCurve) {
4132
throw std::runtime_error("Not yet implemented");
4233
}
4334

packages/react-native-quick-crypto/cpp/keys/HybridKeyObjectHandle.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@ class HybridKeyObjectHandle : public HybridKeyObjectHandleSpec {
1818
HybridKeyObjectHandle() : HybridObject(TAG) {}
1919

2020
public:
21-
std::shared_ptr<ArrayBuffer> exportKey(std::optional<KFormatType> format, std::optional<KeyEncoding> type, const std::optional<std::string>& cipher, const std::optional<std::shared_ptr<ArrayBuffer>>& passphrase) override;
21+
std::shared_ptr<ArrayBuffer> exportKey(std::optional<KFormatType> format, std::optional<KeyEncoding> type,
22+
const std::optional<std::string>& cipher,
23+
const std::optional<std::shared_ptr<ArrayBuffer>>& passphrase) override;
2224
JWK exportJwk(const JWK& key, bool handleRsaPss) override;
2325
CFRGKeyPairType getAsymmetricKeyType() override;
24-
bool init(KeyType keyType, const std::variant<std::string, std::shared_ptr<ArrayBuffer>>& key, std::optional<KFormatType> format, std::optional<KeyEncoding> type, const std::optional<std::shared_ptr<ArrayBuffer>>& passphrase) override;
26+
bool init(KeyType keyType, const std::variant<std::string, std::shared_ptr<ArrayBuffer>>& key, std::optional<KFormatType> format,
27+
std::optional<KeyEncoding> type, const std::optional<std::shared_ptr<ArrayBuffer>>& passphrase) override;
2528
bool initECRaw(const std::string& curveName, const std::shared_ptr<ArrayBuffer>& keyData) override;
2629
std::optional<KeyType> initJwk(const JWK& keyData, std::optional<NamedCurve> namedCurve) override;
2730
KeyDetail keyDetail() override;

packages/react-native-quick-crypto/cpp/utils/Utils.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
#include <algorithm>
44
#include <cctype>
55
#include <limits>
6-
#include <string>
76
#include <openssl/err.h>
7+
#include <string>
88

99
#include <NitroModules/ArrayBuffer.hpp>
1010

1111
namespace margelo::nitro::crypto {
1212

1313
// Function to get the last OpenSSL error message
1414
inline std::string getOpenSSLError() {
15-
unsigned long errCode = ERR_get_error();
16-
if (errCode == 0) {
17-
return "";
18-
}
19-
char errStr[256];
20-
ERR_error_string_n(errCode, errStr, sizeof(errStr));
21-
return std::string(errStr);
15+
unsigned long errCode = ERR_get_error();
16+
if (errCode == 0) {
17+
return "";
18+
}
19+
char errStr[256];
20+
ERR_error_string_n(errCode, errStr, sizeof(errStr));
21+
return std::string(errStr);
2222
}
2323

2424
// copy a JSArrayBuffer that we do not own into a NativeArrayBuffer that we do own

0 commit comments

Comments
 (0)