diff --git a/aead/xchacha20poly1305_ietf/xchacha20poly1305_ietf.v b/aead/xchacha20poly1305_ietf/xchacha20poly1305_ietf.v index 663a6a4..f36d4c7 100644 --- a/aead/xchacha20poly1305_ietf/xchacha20poly1305_ietf.v +++ b/aead/xchacha20poly1305_ietf/xchacha20poly1305_ietf.v @@ -3,12 +3,10 @@ module xchacha20poly1305_ietf import libsodium import math -const ( - crypto_aead_xchacha20poly1305_ietf_abytes = libsodium.crypto_aead_xchacha20poly1305_ietf_abytes() - crypto_aead_xchacha20poly1305_ietf_keybytes = libsodium.crypto_aead_xchacha20poly1305_ietf_keybytes() - crypto_aead_xchacha20poly1305_ietf_npubbytes = libsodium.crypto_aead_xchacha20poly1305_ietf_npubbytes() - crypto_aead_xchacha20poly1305_ietf_messagebytes_max = libsodium.crypto_aead_xchacha20poly1305_ietf_messagebytes_max() -) +const crypto_aead_xchacha20poly1305_ietf_abytes = libsodium.crypto_aead_xchacha20poly1305_ietf_abytes() +const crypto_aead_xchacha20poly1305_ietf_keybytes = libsodium.crypto_aead_xchacha20poly1305_ietf_keybytes() +const crypto_aead_xchacha20poly1305_ietf_npubbytes = libsodium.crypto_aead_xchacha20poly1305_ietf_npubbytes() +const crypto_aead_xchacha20poly1305_ietf_messagebytes_max = libsodium.crypto_aead_xchacha20poly1305_ietf_messagebytes_max() // modeled after https://doc.libsodium.org/secret-key_cryptography/aead/chacha20-poly1305/xchacha20-poly1305_construction diff --git a/common.v b/common.v index 7145466..eba0d25 100644 --- a/common.v +++ b/common.v @@ -1,10 +1,8 @@ module libsodium -const ( - crypto_pwhash_argon2id_saltbytes = crypto_pwhash_argon2id_saltbytes() - crypto_pwhash_passwd_min = crypto_pwhash_passwd_min() - crypto_pwhash_passwd_max = crypto_pwhash_passwd_max() -) +const crypto_pwhash_argon2id_saltbytes = crypto_pwhash_argon2id_saltbytes() +const crypto_pwhash_passwd_min = crypto_pwhash_passwd_min() +const crypto_pwhash_passwd_max = crypto_pwhash_passwd_max() // modeled after https://doc.libsodium.org/password_hashing/default_phf diff --git a/secret_box.v b/secret_box.v index 86097af..f6222a2 100644 --- a/secret_box.v +++ b/secret_box.v @@ -1,12 +1,14 @@ module libsodium -pub const ( - key_size = 32 // int(C.crypto_secretbox_KEYBYTES) - nonce_size = 24 // int(C.crypto_secretbox_NONCEBYTES) - mac_size = 16 // int(C.crypto_secretbox_MACBYTES) - public_key_size = 32 // int(C.crypto_secretbox_PUBLICKEYBYTES) - secret_key_size = 32 // int(C.crypto_secretbox_PUBLICKEYBYTES) -) +pub const key_size = 32 // int(C.crypto_secretbox_KEYBYTES) + +pub const nonce_size = 24 // int(C.crypto_secretbox_NONCEBYTES) + +pub const mac_size = 16 // int(C.crypto_secretbox_MACBYTES) + +pub const public_key_size = 32 // int(C.crypto_secretbox_PUBLICKEYBYTES) + +pub const secret_key_size = 32 // int(C.crypto_secretbox_PUBLICKEYBYTES) pub struct SecretBox { nonce [24]u8 diff --git a/secretbox/secretbox.v b/secretbox/secretbox.v index e44f811..a9ca0fd 100644 --- a/secretbox/secretbox.v +++ b/secretbox/secretbox.v @@ -2,12 +2,10 @@ module secretbox import libsodium -const ( - crypto_secretbox_keybytes = libsodium.crypto_secretbox_keybytes() - crypto_secretbox_macbytes = libsodium.crypto_secretbox_macbytes() - crypto_box_messagebytes_max = libsodium.crypto_box_messagebytes_max() - crypto_box_noncebytes = libsodium.crypto_box_noncebytes() -) +const crypto_secretbox_keybytes = libsodium.crypto_secretbox_keybytes() +const crypto_secretbox_macbytes = libsodium.crypto_secretbox_macbytes() +const crypto_box_messagebytes_max = libsodium.crypto_box_messagebytes_max() +const crypto_box_noncebytes = libsodium.crypto_box_noncebytes() // https://doc.libsodium.org/secret-key_cryptography/secretbox diff --git a/sign.v b/sign.v index 02f39ec..79888e5 100644 --- a/sign.v +++ b/sign.v @@ -1,8 +1,6 @@ module libsodium -const ( - sign_len = 64 -) +const sign_len = 64 pub struct SigningKey { secret_key [secret_key_size]u8 diff --git a/translated.c.v b/translated.c.v index 66437dc..58157f0 100644 --- a/translated.c.v +++ b/translated.c.v @@ -13,13 +13,12 @@ type C.UNSIGNED_LONG_LONG = u64 fn C.ULLCAST(x &u64) &C.UNSIGNED_LONG_LONG -const ( // empty enum - blake2b_blockbytes = 0 - blake2b_outbytes = 1 - blake2b_keybytes = 2 - blake2b_saltbytes = 3 - blake2b_personalbytes = 4 -) +// empty enum +const blake2b_blockbytes = 0 +const blake2b_outbytes = 1 +const blake2b_keybytes = 2 +const blake2b_saltbytes = 3 +const blake2b_personalbytes = 4 /* // struct decl name="blake2b_param_" @@ -591,17 +590,16 @@ enum Argon2_type { argon2_id } -const ( // empty enum - argon2_version_number = 0 - argon2_block_size = 1 - argon2_qwords_in_block = 2 - argon2_owords_in_block = 3 - argon2_hwords_in_block = 4 - argon2_512bit_words_in_block = 5 - argon2_addresses_in_block = 6 - argon2_prehash_digest_length = 7 - argon2_prehash_seed_length = 8 -) +// empty enum +const argon2_version_number = 0 +const argon2_block_size = 1 +const argon2_qwords_in_block = 2 +const argon2_owords_in_block = 3 +const argon2_hwords_in_block = 4 +const argon2_512bit_words_in_block = 5 +const argon2_addresses_in_block = 6 +const argon2_prehash_digest_length = 7 +const argon2_prehash_seed_length = 8 // struct decl name="block_" // typedef struct