Started adding Auth doc, added aead doc for specific functions
This commit is contained in:
10 files changed
+242
-72
No files matched your search
+12
-12
@@ -29,18 +29,18 @@ actual object AuthenticatedEncryptionWithAssociatedData {
|
||||
}
|
||||
|
||||
actual fun xChaCha20Poly1305IetfDecrypt(
|
||||
ciphertext: UByteArray,
|
||||
ciphertextAndTag: UByteArray,
|
||||
associatedData: UByteArray,
|
||||
nonce: UByteArray,
|
||||
key: UByteArray
|
||||
): UByteArray {
|
||||
val message = UByteArray(ciphertext.size - crypto_aead_xchacha20poly1305_ietf_ABYTES)
|
||||
val message = UByteArray(ciphertextAndTag.size - crypto_aead_xchacha20poly1305_ietf_ABYTES)
|
||||
val validationResult = sodium.crypto_aead_xchacha20poly1305_ietf_decrypt(
|
||||
message.asByteArray(),
|
||||
null,
|
||||
null,
|
||||
ciphertext.asByteArray(),
|
||||
ciphertext.size.toLong(),
|
||||
ciphertextAndTag.asByteArray(),
|
||||
ciphertextAndTag.size.toLong(),
|
||||
associatedData.asByteArray(),
|
||||
associatedData.size.toLong(),
|
||||
nonce.asByteArray(),
|
||||
@@ -122,18 +122,18 @@ actual object AuthenticatedEncryptionWithAssociatedData {
|
||||
}
|
||||
|
||||
actual fun chaCha20Poly1305IetfDecrypt(
|
||||
ciphertext: UByteArray,
|
||||
ciphertextAndTag: UByteArray,
|
||||
associatedData: UByteArray,
|
||||
nonce: UByteArray,
|
||||
key: UByteArray
|
||||
): UByteArray {
|
||||
val message = UByteArray(ciphertext.size - crypto_aead_chacha20poly1305_ietf_ABYTES)
|
||||
val message = UByteArray(ciphertextAndTag.size - crypto_aead_chacha20poly1305_ietf_ABYTES)
|
||||
val validationResult = sodium.crypto_aead_chacha20poly1305_ietf_decrypt(
|
||||
message.asByteArray(),
|
||||
null,
|
||||
null,
|
||||
ciphertext.asByteArray(),
|
||||
ciphertext.size.toLong(),
|
||||
ciphertextAndTag.asByteArray(),
|
||||
ciphertextAndTag.size.toLong(),
|
||||
associatedData.asByteArray(),
|
||||
associatedData.size.toLong(),
|
||||
nonce.asByteArray(),
|
||||
@@ -215,18 +215,18 @@ actual object AuthenticatedEncryptionWithAssociatedData {
|
||||
}
|
||||
|
||||
actual fun chaCha20Poly1305Decrypt(
|
||||
ciphertext: UByteArray,
|
||||
ciphertextAndTag: UByteArray,
|
||||
associatedData: UByteArray,
|
||||
nonce: UByteArray,
|
||||
key: UByteArray
|
||||
): UByteArray {
|
||||
val message = UByteArray(ciphertext.size - crypto_aead_chacha20poly1305_ABYTES)
|
||||
val message = UByteArray(ciphertextAndTag.size - crypto_aead_chacha20poly1305_ABYTES)
|
||||
val validationResult = sodium.crypto_aead_chacha20poly1305_decrypt(
|
||||
message.asByteArray(),
|
||||
null,
|
||||
null,
|
||||
ciphertext.asByteArray(),
|
||||
ciphertext.size.toLong(),
|
||||
ciphertextAndTag.asByteArray(),
|
||||
ciphertextAndTag.size.toLong(),
|
||||
associatedData.asByteArray(),
|
||||
associatedData.size.toLong(),
|
||||
nonce.asByteArray(),
|
||||
|
||||
+6
-6
@@ -20,9 +20,9 @@ actual object Auth {
|
||||
return mac
|
||||
}
|
||||
|
||||
actual fun authVerify(mac: UByteArray, message: UByteArray, key: UByteArray): Boolean {
|
||||
actual fun authVerify(tag: UByteArray, message: UByteArray, key: UByteArray): Boolean {
|
||||
return sodium.crypto_auth_verify(
|
||||
mac.asByteArray(),
|
||||
tag.asByteArray(),
|
||||
message.asByteArray(),
|
||||
message.size.toLong(),
|
||||
key.asByteArray()
|
||||
@@ -47,12 +47,12 @@ actual object Auth {
|
||||
}
|
||||
|
||||
actual fun authHmacSha256Verify(
|
||||
mac: UByteArray,
|
||||
tag: UByteArray,
|
||||
message: UByteArray,
|
||||
key: UByteArray
|
||||
): Boolean {
|
||||
return sodium.crypto_auth_hmacsha256_verify(
|
||||
mac.asByteArray(),
|
||||
tag.asByteArray(),
|
||||
message.asByteArray(),
|
||||
message.size.toLong(),
|
||||
key.asByteArray()
|
||||
@@ -77,12 +77,12 @@ actual object Auth {
|
||||
}
|
||||
|
||||
actual fun authHmacSha512Verify(
|
||||
mac: UByteArray,
|
||||
tag: UByteArray,
|
||||
message: UByteArray,
|
||||
key: UByteArray
|
||||
): Boolean {
|
||||
return sodium.crypto_auth_hmacsha512_verify(
|
||||
mac.asByteArray(),
|
||||
tag.asByteArray(),
|
||||
message.asByteArray(),
|
||||
message.size.toLong(),
|
||||
key.asByteArray()
|
||||
|
||||
Reference in new issue
Block a user