typo fixes in crypto_box and crypto_aead
This commit is contained in:
parent
4a97dfeebe
commit
ee481d0096
@ -29,7 +29,7 @@ function crypto_aead_chacha20poly1305_ietf_encrypt (c, m, ad, nsec, npub, k) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function crypto_aead_chacha20poly1305_ietf_encrypt_detached (c, mac, m, ad, nsec, npub, k) {
|
function crypto_aead_chacha20poly1305_ietf_encrypt_detached (c, mac, m, ad, nsec, npub, k) {
|
||||||
if (ad === null) return crypto_aead_chacha20poly1305_ietf_encrypt(c, mac, m, new Uint8Array(0), nsec, npub, k)
|
if (ad === null) return crypto_aead_chacha20poly1305_ietf_encrypt_detached(c, mac, m, new Uint8Array(0), nsec, npub, k)
|
||||||
|
|
||||||
assert(c.byteLength === m.byteLength, 'ciphertext should be same length than message')
|
assert(c.byteLength === m.byteLength, 'ciphertext should be same length than message')
|
||||||
assert(npub.byteLength === crypto_aead_chacha20poly1305_ietf_NPUBBYTES,
|
assert(npub.byteLength === crypto_aead_chacha20poly1305_ietf_NPUBBYTES,
|
||||||
@ -90,7 +90,7 @@ function crypto_aead_chacha20poly1305_ietf_decrypt (m, nsec, c, ad, npub, k) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function crypto_aead_chacha20poly1305_ietf_decrypt_detached (m, nsec, c, mac, ad, npub, k) {
|
function crypto_aead_chacha20poly1305_ietf_decrypt_detached (m, nsec, c, mac, ad, npub, k) {
|
||||||
if (ad === null) return crypto_aead_chacha20poly1305_ietf_decrypt(m, nsec, c, mac, new Uint8Array(0), npub, k)
|
if (ad === null) return crypto_aead_chacha20poly1305_ietf_decrypt_detached(m, nsec, c, mac, new Uint8Array(0), npub, k)
|
||||||
|
|
||||||
assert(c.byteLength === m.byteLength, 'message should be same length than ciphertext')
|
assert(c.byteLength === m.byteLength, 'message should be same length than ciphertext')
|
||||||
assert(npub.byteLength === crypto_aead_chacha20poly1305_ietf_NPUBBYTES,
|
assert(npub.byteLength === crypto_aead_chacha20poly1305_ietf_NPUBBYTES,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const { crypto_hash_sha512 } = require('./crypto_hash')
|
const { crypto_hash_sha512 } = require('./crypto_hash')
|
||||||
const { crypto_scalarmult, crypto_scalarmult_base } = require('./crypto_scalarmult')
|
const { crypto_scalarmult, crypto_scalarmult_base } = require('./crypto_scalarmult')
|
||||||
const { randombytes } = require('./randombytes')
|
const { randombytes_buf } = require('./randombytes')
|
||||||
const { crypto_generichash_batch } = require('./crypto_generichash')
|
const { crypto_generichash_batch } = require('./crypto_generichash')
|
||||||
const { crypto_secretbox_open_easy, crypto_secretbox_easy } = require('./crypto_secretbox')
|
const { crypto_secretbox_open_easy, crypto_secretbox_easy } = require('./crypto_secretbox')
|
||||||
const xsalsa20 = require('xsalsa20')
|
const xsalsa20 = require('xsalsa20')
|
||||||
@ -35,7 +35,7 @@ module.exports = {
|
|||||||
function crypto_box_keypair(pk, sk) {
|
function crypto_box_keypair(pk, sk) {
|
||||||
check(pk, crypto_box_PUBLICKEYBYTES)
|
check(pk, crypto_box_PUBLICKEYBYTES)
|
||||||
check(sk, crypto_box_SECRETKEYBYTES)
|
check(sk, crypto_box_SECRETKEYBYTES)
|
||||||
randombytes(sk, 32)
|
randombytes_buf(sk, 32)
|
||||||
return crypto_scalarmult_base(pk, sk)
|
return crypto_scalarmult_base(pk, sk)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user