Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/sync-node-ncrypto.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"node_commit": "b4f23d3619c98bed09af93a21192f6080197a8c6"
"node_commit": "2161c944dc174f8b8960fd633b36a1f0c881d283"
}
46 changes: 31 additions & 15 deletions include/ncrypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,18 @@
#define OPENSSL_WITH_EVP_MAC 0
#endif

#if !defined(OPENSSL_IS_BORINGSSL) && OPENSSL_VERSION_PREREQ(3, 0)
#define OPENSSL_WITH_AES_SIV 1
#else
#define OPENSSL_WITH_AES_SIV 0
#endif

#if !defined(OPENSSL_IS_BORINGSSL) && OPENSSL_VERSION_PREREQ(3, 2)
#define OPENSSL_WITH_AES_GCM_SIV 1
#else
#define OPENSSL_WITH_AES_GCM_SIV 0
#endif

#if defined(OPENSSL_IS_BORINGSSL) || OPENSSL_VERSION_PREREQ(3, 2)
#define OPENSSL_WITH_SIGNATURE_CONTEXT_STRING 1
#else
Expand Down Expand Up @@ -460,9 +472,12 @@ class Cipher final {

Cipher() = default;
Cipher(const EVP_CIPHER* cipher) : cipher_(cipher) {}
Cipher(const Cipher&) = default;
Cipher& operator=(const Cipher&) = default;
Cipher(const Cipher& other);
Cipher& operator=(const Cipher& other);
inline Cipher& operator=(const EVP_CIPHER* cipher) {
#if OPENSSL_WITH_AES_SIV || OPENSSL_WITH_AES_GCM_SIV
fetched_cipher_.reset();
#endif
cipher_ = cipher;
return *this;
}
Expand All @@ -485,6 +500,8 @@ class Cipher final {
bool isCtrMode() const;
bool isCcmMode() const;
bool isOcbMode() const;
bool isSivMode() const;
bool isGcmSivMode() const;
bool isStreamMode() const;
bool isChaCha20Poly1305() const;

Expand Down Expand Up @@ -531,6 +548,7 @@ class Cipher final {
struct CipherParams {
int padding;
Digest digest;
Digest mgf1_digest;
const Buffer<const void> label;
};

Expand All @@ -555,6 +573,10 @@ class Cipher final {

private:
const EVP_CIPHER* cipher_ = nullptr;
#if OPENSSL_WITH_AES_SIV || OPENSSL_WITH_AES_GCM_SIV
explicit Cipher(DeleteFnPtr<EVP_CIPHER, EVP_CIPHER_free> cipher);
DeleteFnPtr<EVP_CIPHER, EVP_CIPHER_free> fetched_cipher_;
#endif
};

// ============================================================================
Expand Down Expand Up @@ -965,6 +987,8 @@ class CipherCtxPointer final {
bool isOcbMode() const;
bool isCcmMode() const;
bool isWrapMode() const;
bool isSivMode() const;
bool isGcmSivMode() const;
bool isChaCha20Poly1305() const;

bool update(const Buffer<const unsigned char>& in,
Expand Down Expand Up @@ -1260,9 +1284,9 @@ class DHPointer final {
UNABLE_TO_CHECK_GENERATOR = 0x04,
NOT_SUITABLE_GENERATOR = 0x08,
Q_NOT_PRIME = 0x10,
#ifndef OPENSSL_IS_BORINGSSL
// Boringssl does not define the DH_CHECK_INVALID_[Q or J]_VALUE
INVALID_Q = 0x20,
#ifndef OPENSSL_IS_BORINGSSL
// BoringSSL does not define DH_CHECK_INVALID_J_VALUE.
INVALID_J = 0x40,
MODULUS_TOO_SMALL = 0x80,
MODULUS_TOO_LARGE = 0x100,
Expand All @@ -1273,14 +1297,9 @@ class DHPointer final {

enum class CheckPublicKeyResult {
NONE,
#ifndef OPENSSL_IS_BORINGSSL
// Boringssl does not define DH_R_CHECK_PUBKEY_TOO_SMALL or TOO_LARGE
TOO_SMALL = DH_R_CHECK_PUBKEY_TOO_SMALL,
TOO_LARGE = DH_R_CHECK_PUBKEY_TOO_LARGE,
INVALID = DH_R_CHECK_PUBKEY_INVALID,
#else
INVALID = DH_R_INVALID_PUBKEY,
#endif
TOO_SMALL,
TOO_LARGE,
INVALID,
CHECK_FAILED = 512,
};
// Check to see if the given public key is suitable for this DH instance.
Expand Down Expand Up @@ -1375,9 +1394,6 @@ class SSLPointer final {
bool setSession(const SSLSessionPointer& session);
bool setSniContext(const SSLCtxPointer& ctx) const;

const char* getClientHelloAlpn() const;
const char* getClientHelloServerName() const;

std::optional<const std::string_view> getServerName() const;
X509View getCertificate() const;
EVPKeyPointer getPeerTempKey() const;
Expand Down
Loading
Loading