Skip to content

Commit

Permalink
Add missing crypto_box_curve25519xchacha20poly1305_* functions
Browse files Browse the repository at this point in the history
  • Loading branch information
danielecaggiari committed Apr 7, 2023
1 parent 3fe78da commit b0297b4
Show file tree
Hide file tree
Showing 9 changed files with 353 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "crypto_box_curve25519xchacha20poly1305_detached",
"type": "function",
"inputs": [
{
"name": "message",
"type": "unsized_buf"
},
{
"name": "nonce",
"type": "buf",
"length": "libsodium._crypto_box_curve25519xchacha20poly1305_noncebytes()"
},
{
"name": "publicKey",
"type": "buf",
"length": "libsodium._crypto_box_curve25519xchacha20poly1305_publickeybytes()"
},
{
"name": "privateKey",
"type": "buf",
"length": "libsodium._crypto_box_curve25519xchacha20poly1305_secretkeybytes()"
}
],
"outputs": [
{
"name": "ciphertext",
"type": "buf",
"length": "message_length"
},
{
"name": "mac",
"type": "buf",
"length": "libsodium._crypto_box_curve25519xchacha20poly1305_macbytes()"
}
],
"target": "libsodium._crypto_box_curve25519xchacha20poly1305_detached(ciphertext_address, mac_address, message_address, message_length, 0, nonce_address, publicKey_address, privateKey_address) | 0",
"assert_retval": [
{
"condition": "=== 0",
"or_else_throw": "invalid usage"
}
],
"return": "_format_output({ciphertext: ciphertext, mac: mac}, outputFormat)"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "crypto_box_curve25519xchacha20poly1305_detached_afternm",
"type": "function",
"inputs": [
{
"name": "message",
"type": "unsized_buf"
},
{
"name": "nonce",
"type": "buf",
"length": "libsodium._crypto_box_curve25519xchacha20poly1305_noncebytes()"
},
{
"name": "sharedKey",
"type": "buf",
"length": "libsodium._crypto_box_curve25519xchacha20poly1305_beforenmbytes()"
}
],
"outputs": [
{
"name": "ciphertext",
"type": "buf",
"length": "message_length"
},
{
"name": "mac",
"type": "buf",
"length": "libsodium._crypto_box_curve25519xchacha20poly1305_macbytes()"
}
],
"target": "libsodium._crypto_box_curve25519xchacha20poly1305_detached_afternm(ciphertext_address, mac_address, message_address, message_length, 0, nonce_address, sharedKey_address) | 0",
"assert_retval": [
{
"condition": "=== 0",
"or_else_throw": "invalid usage"
}
],
"return": "_format_output({ciphertext: ciphertext, mac: mac}, outputFormat)"
}
40 changes: 40 additions & 0 deletions wrapper/symbols/crypto_box_curve25519xchacha20poly1305_easy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "crypto_box_curve25519xchacha20poly1305_easy",
"type": "function",
"inputs": [
{
"name": "message",
"type": "unsized_buf"
},
{
"name": "nonce",
"type": "buf",
"length": "libsodium._crypto_box_curve25519xchacha20poly1305_noncebytes()"
},
{
"name": "publicKey",
"type": "buf",
"length": "libsodium._crypto_box_curve25519xchacha20poly1305_publickeybytes()"
},
{
"name": "privateKey",
"type": "buf",
"length": "libsodium._crypto_box_curve25519xchacha20poly1305_secretkeybytes()"
}
],
"outputs": [
{
"name": "ciphertext",
"type": "buf",
"length": "message_length + libsodium._crypto_box_curve25519xchacha20poly1305_macbytes()"
}
],
"target": "libsodium._crypto_box_curve25519xchacha20poly1305_easy(ciphertext_address, message_address, message_length, 0, nonce_address, publicKey_address, privateKey_address) | 0",
"assert_retval": [
{
"condition": "=== 0",
"or_else_throw": "invalid usage"
}
],
"return": "_format_output(ciphertext, outputFormat)"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "crypto_box_curve25519xchacha20poly1305_easy_afternm",
"type": "function",
"inputs": [
{
"name": "message",
"type": "unsized_buf"
},
{
"name": "nonce",
"type": "buf",
"length": "libsodium._crypto_box_curve25519xchacha20poly1305_noncebytes()"
},
{
"name": "sharedKey",
"type": "buf",
"length": "libsodium._crypto_box_curve25519xchacha20poly1305_beforenmbytes()"
}
],
"outputs": [
{
"name": "ciphertext",
"type": "buf",
"length": "message_length + libsodium._crypto_box_curve25519xchacha20poly1305_macbytes()"
}
],
"target": "libsodium._crypto_box_curve25519xchacha20poly1305_easy_afternm(ciphertext_address, message_address, message_length, 0, nonce_address, sharedKey_address) | 0",
"assert_retval": [
{
"condition": "=== 0",
"or_else_throw": "invalid usage"
}
],
"return": "_format_output(ciphertext, outputFormat)"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "crypto_box_curve25519xchacha20poly1305_open_detached",
"type": "function",
"inputs": [
{
"name": "ciphertext",
"type": "unsized_buf"
},
{
"name": "mac",
"type": "buf",
"length": "libsodium._crypto_box_curve25519xchacha20poly1305_macbytes()"
},
{
"name": "nonce",
"type": "buf",
"length": "libsodium._crypto_box_curve25519xchacha20poly1305_noncebytes()"
},
{
"name": "publicKey",
"type": "buf",
"length": "libsodium._crypto_box_curve25519xchacha20poly1305_publickeybytes()"
},
{
"name": "privateKey",
"type": "buf",
"length": "libsodium._crypto_box_curve25519xchacha20poly1305_secretkeybytes()"
}
],
"outputs": [
{
"name": "plaintext",
"type": "buf",
"length": "ciphertext_length"
}
],
"target": "libsodium._crypto_box_curve25519xchacha20poly1305_open_detached(plaintext_address, ciphertext_address, mac_address, ciphertext_length, 0, nonce_address, publicKey_address, privateKey_address) | 0",
"assert_retval": [
{
"condition": "=== 0",
"or_else_throw": "incorrect key pair for the given ciphertext"
}
],
"return": "_format_output(plaintext, outputFormat)"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "crypto_box_curve25519xchacha20poly1305_open_detached_afternm",
"type": "function",
"inputs": [
{
"name": "ciphertext",
"type": "unsized_buf"
},
{
"name": "mac",
"type": "buf",
"length": "libsodium._crypto_box_curve25519xchacha20poly1305_macbytes()"
},
{
"name": "nonce",
"type": "buf",
"length": "libsodium._crypto_box_curve25519xchacha20poly1305_noncebytes()"
},
{
"name": "sharedKey",
"type": "buf",
"length": "libsodium._crypto_box_curve25519xchacha20poly1305_beforenmbytes()"
}
],
"outputs": [
{
"name": "plaintext",
"type": "buf",
"length": "ciphertext_length"
}
],
"target": "libsodium._crypto_box_curve25519xchacha20poly1305_open_detached_afternm(plaintext_address, ciphertext_address, mac_address, ciphertext_length, 0, nonce_address, sharedKey_address) | 0",
"assert_retval": [
{
"condition": "=== 0",
"or_else_throw": "incorrect secret key for the given ciphertext"
}
],
"return": "_format_output(plaintext, outputFormat)"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "crypto_box_curve25519xchacha20poly1305_open_easy",
"type": "function",
"inputs": [
{
"name": "ciphertext",
"type": "minsized_buf",
"min_length": "libsodium._crypto_box_curve25519xchacha20poly1305_macbytes()"
},
{
"name": "nonce",
"type": "buf",
"length": "libsodium._crypto_box_curve25519xchacha20poly1305_noncebytes()"
},
{
"name": "publicKey",
"type": "buf",
"length": "libsodium._crypto_box_curve25519xchacha20poly1305_publickeybytes()"
},
{
"name": "privateKey",
"type": "buf",
"length": "libsodium._crypto_box_curve25519xchacha20poly1305_secretkeybytes()"
}
],
"outputs": [
{
"name": "plaintext",
"type": "buf",
"length": "ciphertext_length - libsodium._crypto_box_curve25519xchacha20poly1305_macbytes()"
}
],
"target": "libsodium._crypto_box_curve25519xchacha20poly1305_open_easy(plaintext_address, ciphertext_address, ciphertext_length, 0, nonce_address, publicKey_address, privateKey_address) | 0",
"assert_retval": [
{
"condition": "=== 0",
"or_else_throw": "incorrect key pair for the given ciphertext"
}
],
"return": "_format_output(plaintext, outputFormat)"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "crypto_box_curve25519xchacha20poly1305_open_easy_afternm",
"type": "function",
"inputs": [
{
"name": "ciphertext",
"type": "unsized_buf",
"length": "libsodium._crypto_box_curve25519xchacha20poly1305_macbytes()"
},
{
"name": "nonce",
"type": "buf",
"length": "libsodium._crypto_box_curve25519xchacha20poly1305_noncebytes()"
},
{
"name": "sharedKey",
"type": "buf",
"length": "libsodium._crypto_box_curve25519xchacha20poly1305_beforenmbytes()"
}
],
"outputs": [
{
"name": "plaintext",
"type": "buf",
"length": "ciphertext_length - libsodium._crypto_box_curve25519xchacha20poly1305_macbytes()"
}
],
"target": "libsodium._crypto_box_curve25519xchacha20poly1305_open_easy_afternm(plaintext_address, ciphertext_address, ciphertext_length, 0, nonce_address, sharedKey_address) | 0",
"assert_retval": [
{
"condition": "=== 0",
"or_else_throw": "incorrect secret key for the given ciphertext"
}
],
"return": "_format_output(plaintext, outputFormat)"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "crypto_box_curve25519xchacha20poly1305_seed_keypair",
"type": "function",
"inputs": [
{
"name": "seed",
"type": "buf",
"length": "libsodium._crypto_box_curve25519xchacha20poly1305_seedbytes()"
}
],
"outputs": [
{
"name": "publicKey",
"length": "libsodium._crypto_box_curve25519xchacha20poly1305_publickeybytes()",
"type": "buf"
},
{
"name": "privateKey",
"type": "buf",
"length": "libsodium._crypto_box_curve25519xchacha20poly1305_secretkeybytes()"
}
],
"target": "libsodium._crypto_box_curve25519xchacha20poly1305_seed_keypair(publicKey_address, privateKey_address, seed_address) | 0",
"assert_retval": [
{
"condition": "=== 0",
"or_else_throw": "invalid usage"
}
],
"return": "{publicKey: _format_output(publicKey, outputFormat), privateKey: _format_output(privateKey, outputFormat), keyType: 'x25519'}"
}

0 comments on commit b0297b4

Please sign in to comment.