Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split library into modules #20

Merged
merged 52 commits into from
Jun 18, 2020
Merged

Conversation

chm-diederichs
Copy link
Collaborator

No description provided.

Copy link
Collaborator Author

@chm-diederichs chm-diederichs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see
942c2a6, a4cab9d.
function signature changed to libsodium signature.

crypto_stream.js Outdated
exports.crypto_stream = function (out, nonce, key) {
out.fill(0)
exports.crypto_stream_xor(out, out, nonce, key)
exports.crypto_stream = function (c, cpos, clen, nonce, key) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see a4cab9d

@emilbayes
Copy link
Member

Looks great! Now we have them split we can start cleaning up. Stuff like check to assert and ensuring TypedArrays everywhere, and becoming compatible with sodium-native (I see some legacy return values)

@emilbayes emilbayes self-requested a review May 5, 2020 09:08
@mafintosh
Copy link
Member

@emilbayes we have ensure endianess also yes?

@emilbayes
Copy link
Member

Oh yeah, let's make issues

@chm-diederichs
Copy link
Collaborator Author

chm-diederichs commented Jun 12, 2020

depends on #21

  • for chacha20 support

@emilbayes
Copy link
Member

I think we should just fail on BE for now, globally

crypto_verify.js Outdated
}

function sodium_memcmp (a, b) {
assert(a.byteLength = b.byteLength, 'buffers must be the same size')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am just a casual observer of this PR as I am excited about this! but it looks like the equality comparison is missing another = character here, unless I am missing something

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! fixed in 56416de

crypto_aead.js Outdated
function write64LE (buf, int) {
buf.fill(0, 0, 8)
buf.writeUInt32LE(int & 0xffffffff)
buf.writeUInt32LE((int >> 32) & 0xffffffff)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this is buffer only

crypto_box.js Outdated

const hash = Buffer.alloc(64)
crypto_hash_sha512(hash, seed, 32)
hash.copy(sk, 0, 0, 32)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use .set to copy sk.set(hash, ) with typedarrays


function crypto_sign_seed_keypair (pk, sk, seed) {
check(seed, crypto_sign_SEEDBYTES)
seed.copy(sk)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use sk.set(seed)

crypto_aead.js Outdated

var ret = -1

if (c.length >= crypto_aead_chacha20poly1305_ietf_ABYTES) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can return early here instead of a nested conditional perhaps?

crypto_aead.js Outdated
Comment on lines 149 to 150
crypto_stream_chacha20_ietf_xor_ic(m, c, npub, 1, k)
return 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct?

@mafintosh mafintosh merged commit b44f83f into sodium-friends:master Jun 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants