Skip to content

Commit ae0c18f

Browse files
panvanpaun
authored andcommitted
crypto: add AES-OCB Web Cryptography algorithm
PR-URL: nodejs/node#59539 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent c1f1003 commit ae0c18f

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

include/ncrypto.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,9 @@ class Cipher final {
380380
static const Cipher AES_128_KW;
381381
static const Cipher AES_192_KW;
382382
static const Cipher AES_256_KW;
383+
static const Cipher AES_128_OCB;
384+
static const Cipher AES_192_OCB;
385+
static const Cipher AES_256_OCB;
383386
static const Cipher CHACHA20_POLY1305;
384387

385388
struct CipherParams {
@@ -755,6 +758,7 @@ class CipherCtxPointer final {
755758
int getNid() const;
756759

757760
bool isGcmMode() const;
761+
bool isOcbMode() const;
758762
bool isCcmMode() const;
759763
bool isWrapMode() const;
760764
bool isChaCha20Poly1305() const;

src/ncrypto.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3201,6 +3201,9 @@ const Cipher Cipher::AES_256_GCM = Cipher::FromNid(NID_aes_256_gcm);
32013201
const Cipher Cipher::AES_128_KW = Cipher::FromNid(NID_id_aes128_wrap);
32023202
const Cipher Cipher::AES_192_KW = Cipher::FromNid(NID_id_aes192_wrap);
32033203
const Cipher Cipher::AES_256_KW = Cipher::FromNid(NID_id_aes256_wrap);
3204+
const Cipher Cipher::AES_128_OCB = Cipher::FromNid(NID_aes_128_ocb);
3205+
const Cipher Cipher::AES_192_OCB = Cipher::FromNid(NID_aes_192_ocb);
3206+
const Cipher Cipher::AES_256_OCB = Cipher::FromNid(NID_aes_256_ocb);
32043207
const Cipher Cipher::CHACHA20_POLY1305 = Cipher::FromNid(NID_chacha20_poly1305);
32053208

32063209
bool Cipher::isGcmMode() const {
@@ -3476,6 +3479,11 @@ bool CipherCtxPointer::isGcmMode() const {
34763479
return getMode() == EVP_CIPH_GCM_MODE;
34773480
}
34783481

3482+
bool CipherCtxPointer::isOcbMode() const {
3483+
if (!ctx_) return false;
3484+
return getMode() == EVP_CIPH_OCB_MODE;
3485+
}
3486+
34793487
bool CipherCtxPointer::isCcmMode() const {
34803488
if (!ctx_) return false;
34813489
return getMode() == EVP_CIPH_CCM_MODE;

0 commit comments

Comments
 (0)