From 36193d05567f5d7648a55ffbc916086baa635a77 Mon Sep 17 00:00:00 2001 From: Brad Anderson Date: Sat, 27 Apr 2024 08:32:48 -0400 Subject: [PATCH] chore: docs for implementation coverage current status (#282) --- implementation-coverage.md | 189 ++++++++++++++++++++++++++---- src/@types/crypto-browserify.d.ts | 4 - 2 files changed, 169 insertions(+), 24 deletions(-) delete mode 100644 src/@types/crypto-browserify.d.ts diff --git a/implementation-coverage.md b/implementation-coverage.md index d40ed2fd..b0c55642 100644 --- a/implementation-coverage.md +++ b/implementation-coverage.md @@ -1,33 +1,182 @@ # Implementation Coverage This document attempts to describe the implementation status of Crypto APIs/Interfaces from Node.js in the `react-native-quick-crypto` library. +* ❌ - implemented in Node, not RNQC +* ✅ - implemented in Node and RNQC + # `Crypto` -> 🚧 needs to be filled out completely -## `encrypt` -| Algorithm | Status | -| --------- | :----: | -| `AES-CBC` | | -| `AES-CCM` | | -| `AES-CTR` | | -| `AES-GCM` | ✅ | -| `chacha20` | | -| `chacha20-poly1305` | | +* ❌ Class: `Certificate` + * ❌ Static method: `Certificate.exportChallenge(spkac[, encoding])` + * ❌ Static method: `Certificate.exportPublicKey(spkac[, encoding])` + * ❌ Static method: `Certificate.verifySpkac(spkac[, encoding])` +* ✅ Class: `Cipher` + * ✅ `cipher.final([outputEncoding])` + * ✅ `cipher.getAuthTag()` + * ✅ `cipher.setAAD(buffer[, options])` + * ✅ `cipher.setAutoPadding([autoPadding])` + * ✅ `cipher.update(data[, inputEncoding][, outputEncoding])` +* ✅ Class: `Decipher` + * ✅ `decipher.final([outputEncoding])` + * ✅ `decipher.setAAD(buffer[, options])` + * ✅ `decipher.setAuthTag(buffer[, encoding])` + * ✅ `decipher.setAutoPadding([autoPadding])` + * ✅ `decipher.update(data[, inputEncoding][, outputEncoding])` +* ❌ Class: `DiffieHellman` + * ❌ `diffieHellman.computeSecret(otherPublicKey[, inputEncoding][, outputEncoding])` + * ❌ `diffieHellman.generateKeys([encoding])` + * ❌ `diffieHellman.getGenerator([encoding])` + * ❌ `diffieHellman.getPrime([encoding])` + * ❌ `diffieHellman.getPrivateKey([encoding])` + * ❌ `diffieHellman.getPublicKey([encoding])` + * ❌ `diffieHellman.setPrivateKey(privateKey[, encoding])` + * ❌ `diffieHellman.setPublicKey(publicKey[, encoding])` + * ❌ `diffieHellman.verifyError` +* ❌ Class: `DiffieHellmanGroup` +* ❌ Class: `ECDH` + * ❌ `Static method: ECDH.convertKey(key, curve[, inputEncoding[, outputEncoding[, format]]])` + * ❌ `ecdh.computeSecret(otherPublicKey[, inputEncoding][, outputEncoding])` + * ❌ `ecdh.generateKeys([encoding[, format]])` + * ❌ `ecdh.getPrivateKey([encoding])` + * ❌ `ecdh.getPublicKey([encoding][, format])` + * ❌ `ecdh.setPrivateKey(privateKey[, encoding])` + * ❌ `ecdh.setPublicKey(publicKey[, encoding])` +* ✅ Class: `Hash` + * ✅ `hash.copy([options])` + * ✅ `hash.digest([encoding])` + * ✅ `hash.update(data[, inputEncoding])` +* ✅ Class: `Hmac` + * ✅ `hmac.digest([encoding])` + * ✅ `hmac.update(data[, inputEncoding])` +* 🚧 Class: `KeyObject` + * ❌ `Static method: KeyObject.from(key)` + * ❌ `keyObject.asymmetricKeyDetails` + * ✅ `keyObject.asymmetricKeyType` + * ✅ `keyObject.export([options])` + * ❌ `keyObject.equals(otherKeyObject)` + * ❌ `keyObject.symmetricKeySize` + * ❌ `keyObject.type` +* ✅ Class: `Sign` + * ✅ `sign.sign(privateKey[, outputEncoding])` + * ✅ `sign.update(data[, inputEncoding])` +* ✅ Class: `Verify` + * ✅ `verify.update(data[, inputEncoding])` + * ✅ `verify.verify(object, signature[, signatureEncoding])` +* ❌ Class: `X509Certificate` + * ❌ `new X509Certificate(buffer)` + * ❌ `x509.ca` + * ❌ `x509.checkEmail(email[, options])` + * ❌ `x509.checkHost(name[, options])` + * ❌ `x509.checkIP(ip)` + * ❌ `x509.checkIssued(otherCert)` + * ❌ `x509.checkPrivateKey(privateKey)` + * ❌ `x509.fingerprint` + * ❌ `x509.fingerprint256` + * ❌ `x509.fingerprint512` + * ❌ `x509.infoAccess` + * ❌ `x509.issuer` + * ❌ `x509.issuerCertificate` + * ❌ `x509.extKeyUsage` + * ❌ `x509.publicKey` + * ❌ `x509.raw` + * ❌ `x509.serialNumber` + * ❌ `x509.subject` + * ❌ `x509.subjectAltName` + * ❌ `x509.toJSON()` + * ❌ `x509.toLegacyObject()` + * ❌ `x509.toString()` + * ❌ `x509.validFrom` + * ❌ `x509.validTo` + * ❌ `x509.verify(publicKey)` +* 🚧 node:crypto module methods and properties + * ✅ `crypto.constants` + * ❌ `crypto.fips` + * ❌ `crypto.checkPrime(candidate[, options], callback)` + * ❌ `crypto.checkPrimeSync(candidate[, options])` + * ✅ `crypto.createCipheriv(algorithm, key, iv[, options])` + * ✅ `crypto.createDecipheriv(algorithm, key, iv[, options])` + * ❌ `crypto.createDiffieHellman(prime[, primeEncoding][, generator][, generatorEncoding])` + * ❌ `crypto.createDiffieHellman(primeLength[, generator])` + * ❌ `crypto.createDiffieHellmanGroup(name)` + * ❌ `crypto.createECDH(curveName)` + * ✅ `crypto.createHash(algorithm[, options])` + * ✅ `crypto.createHmac(algorithm, key[, options])` + * ❌ `crypto.createPrivateKey(key)` + * ❌ `crypto.createPublicKey(key)` + * ❌ `crypto.createSecretKey(key[, encoding])` + * ✅ `crypto.createSign(algorithm[, options])` + * ✅ `crypto.createVerify(algorithm[, options])` + * ❌ `crypto.diffieHellman(options)` + * ❌ `crypto.hash(algorithm, data[, outputEncoding])` + * ❌ `crypto.generateKey(type, options, callback)` + * ✅ `crypto.generateKeyPair(type, options, callback)` + * ✅ `crypto.generateKeyPairSync(type, options)` + * ❌ `crypto.generateKeySync(type, options)` + * ❌ `crypto.generatePrime(size[, options[, callback]])` + * ❌ `crypto.generatePrimeSync(size[, options])` + * ❌ `crypto.getCipherInfo(nameOrNid[, options])` + * ✅ `crypto.getCiphers()` + * ❌ `crypto.getCurves()` + * ❌ `crypto.getDiffieHellman(groupName)` + * ❌ `crypto.getFips()` + * ✅ `crypto.getHashes()` + * ✅ `crypto.getRandomValues(typedArray)` + * ❌ `crypto.hkdf(digest, ikm, salt, info, keylen, callback)` + * ❌ `crypto.hkdfSync(digest, ikm, salt, info, keylen)` + * ✅ `crypto.pbkdf2(password, salt, iterations, keylen, digest, callback)` + * ✅ `crypto.pbkdf2Sync(password, salt, iterations, keylen, digest)` + * ❌ `crypto.privateDecrypt(privateKey, buffer)` + * ❌ `crypto.privateEncrypt(privateKey, buffer)` + * ✅ `crypto.publicDecrypt(key, buffer)` + * ✅ `crypto.publicEncrypt(key, buffer)` + * ✅ `crypto.randomBytes(size[, callback])` + * ✅ `crypto.randomFillSync(buffer[, offset][, size])` + * ✅ `crypto.randomFill(buffer[, offset][, size], callback)` + * ✅ `crypto.randomInt([min, ]max[, callback])` + * ✅ `crypto.randomUUID([options])` + * ❌ `crypto.scrypt(password, salt, keylen[, options], callback)` + * ❌ `crypto.scryptSync(password, salt, keylen[, options])` + * ❌ `crypto.secureHeapUsed()` + * ❌ `crypto.setEngine(engine[, flags])` + * ❌ `crypto.setFips(bool)` + * ❌ `crypto.sign(algorithm, data, key[, callback])` + * 🚧 `crypto.subtle` (see below) + * ❌ `crypto.timingSafeEqual(a, b)` + * ❌ `crypto.verify(algorithm, data, key, signature[, callback])` + * 🚧 `crypto.webcrypto` (see below) -## `decrypt` -| Algorithm | Status | -| --------- | :----: | -| `AES-CBC` | | -| `AES-CCM` | | -| `AES-CTR` | | -| `AES-GCM` | ✅ | -| `chacha20` | | -| `chacha20-poly1305` | | +# `WebCrypto` +* 🚧 Class: `Crypto` + * 🚧 `crypto.subtle` + * ✅ `crypto.getRandomValues(typedArray)` + * ✅ `crypto.randomUUID()` +* ✅ Class: `CryptoKey` + * ✅ `cryptoKey.algorithm` + * ✅ `cryptoKey.extractable` + * ✅ `cryptoKey.type` + * ✅ `cryptoKey.usages` +* ❌ Class: `CryptoKeyPair` + * ❌ `cryptoKeyPair.privateKey` + * ❌ `cryptoKeyPair.publicKey` +* 🚧 Class: `CryptoSubtle` + * (see below) # `SubtleCrypto` -> Note: A lot of isomorphic packages check the availability of `crypto.subtle` and use it instead of `crypto`. Until `crypto.subtle` is feature-complete, you might want to set it to `undefined` so that `crypto` gets used instead for transitive dependencies. +* 🚧 Class: `SubtleCrypto` + * ❌ `subtle.decrypt(algorithm, key, data)` + * 🚧 `subtle.deriveBits(algorithm, baseKey, length)` + * ❌ `subtle.deriveKey(algorithm, baseKey, derivedKeyAlgorithm, extractable, keyUsages)` + * ✅ `subtle.digest(algorithm, data)` + * ❌ `subtle.encrypt(algorithm, key, data)` + * 🚧 `subtle.exportKey(format, key)` + * ❌ `subtle.generateKey(algorithm, extractable, keyUsages)` + * 🚧 `subtle.importKey(format, keyData, algorithm, extractable, keyUsages)` + * ❌ `subtle.sign(algorithm, key, data)` + * ❌ `subtle.unwrapKey(format, wrappedKey, unwrappingKey, unwrapAlgo, unwrappedKeyAlgo, extractable, keyUsages)` + * ❌ `subtle.verify(algorithm, key, signature, data)` + * ❌ `subtle.wrapKey(format, key, wrappingKey, wrapAlgo)` ## `encrypt` | Algorithm | Status | diff --git a/src/@types/crypto-browserify.d.ts b/src/@types/crypto-browserify.d.ts deleted file mode 100644 index 736ed1aa..00000000 --- a/src/@types/crypto-browserify.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -declare module 'crypto-browserify' { - import Crypto from 'crypto'; - export = Crypto; -}