Added secretbox functions and constants
This commit is contained in:
1 parent
555b69f15c
commit
99b9ee5e9d
14 files changed
+464
-32
No files matched your search
+30
@@ -0,0 +1,30 @@
|
||||
package com.ionspin.kotlin.crypto.secretbox
|
||||
|
||||
import kotlin.js.JsName
|
||||
|
||||
/**
|
||||
* Created by Ugljesa Jovanovic
|
||||
* ugljesa.jovanovic@ionspin.com
|
||||
* on 29-Aug-2020
|
||||
*/
|
||||
|
||||
val crypto_secretbox_KEYBYTES = 32
|
||||
val crypto_secretbox_MACBYTES = 16
|
||||
val crypto_secretbox_NONCEBYTES = 24
|
||||
|
||||
class SecretBoxCorruptedOrTamperedDataExceptionOrInvalidKey() : RuntimeException("MAC validation failed. Data is corrupted or tampered with.")
|
||||
|
||||
data class SecretBoxEncryptedDataAndTag(
|
||||
@JsName("data")
|
||||
val data: UByteArray, val tag: UByteArray)
|
||||
|
||||
expect object SecretBox {
|
||||
|
||||
fun easy(message : UByteArray, nonce: UByteArray, key: UByteArray) : UByteArray
|
||||
fun openEasy(ciphertext: UByteArray, nonce: UByteArray, key: UByteArray) : UByteArray
|
||||
|
||||
fun detached(message: UByteArray, nonce: UByteArray, key: UByteArray) : SecretBoxEncryptedDataAndTag
|
||||
fun openDetached(ciphertext: UByteArray, tag: UByteArray, nonce: UByteArray, key: UByteArray) : UByteArray
|
||||
|
||||
fun keygen() : UByteArray
|
||||
}
|
||||
+4
@@ -4,6 +4,8 @@ package com.ionspin.kotlin.crypto.secretstream
|
||||
* Created by Ugljesa Jovanovic
|
||||
* ugljesa.jovanovic@ionspin.com
|
||||
* on 26-Aug-2020
|
||||
*
|
||||
* This file is named with Jvm suffix because of https://youtrack.jetbrains.com/issue/KT-21186
|
||||
*/
|
||||
expect class SecretStreamState
|
||||
|
||||
@@ -20,6 +22,8 @@ val crypto_secretstream_xchacha20poly1305_HEADERBYTES = 24
|
||||
val crypto_secretstream_xchacha20poly1305_KEYBYTES = 32
|
||||
val crypto_secretstream_xchacha20poly1305_ABYTES = 17
|
||||
|
||||
class SecretStreamCorrupedOrTamperedDataException() : RuntimeException("MAC validation failed. Data is corrupted or tampered with.")
|
||||
|
||||
expect object SecretStream {
|
||||
|
||||
fun xChaCha20Poly1305InitPush(key: UByteArray) : SecretStreamStateAndHeader
|
||||
|
||||
Reference in new issue
Block a user