subtle.mx raw
1 package subtle
2
3 // SubtleCrypto bridge: AES-CBC, AES-GCM, PBKDF2, Argon2id, random bytes.
4 // Available in both window and service worker scopes.
5
6 // RandomBytes fills dst with cryptographically random bytes.
7 func RandomBytes(dst []byte) { panic("jsbridge") }
8
9 // AESCBCEncrypt encrypts plaintext with AES-256-CBC.
10 // key: 32 bytes, iv: 16 bytes.
11 func AESCBCEncrypt(key, iv, plaintext []byte, fn func([]byte)) { panic("jsbridge") }
12
13 // AESCBCDecrypt decrypts ciphertext with AES-256-CBC.
14 // key: 32 bytes, iv: 16 bytes.
15 func AESCBCDecrypt(key, iv, ciphertext []byte, fn func([]byte)) { panic("jsbridge") }
16
17 // AESGCMEncrypt encrypts plaintext with AES-256-GCM.
18 // key: 32 bytes, iv: 12 bytes. Ciphertext includes 16-byte auth tag.
19 func AESGCMEncrypt(key, iv, plaintext []byte, fn func([]byte)) { panic("jsbridge") }
20
21 // AESGCMDecrypt decrypts ciphertext with AES-256-GCM.
22 // key: 32 bytes, iv: 12 bytes. Returns empty slice on auth failure.
23 func AESGCMDecrypt(key, iv, ciphertext []byte, fn func([]byte)) { panic("jsbridge") }
24
25 // PBKDF2DeriveKey derives a 32-byte key using PBKDF2-SHA256.
26 // salt is raw bytes, iterations is the iteration count.
27 func PBKDF2DeriveKey(password string, salt []byte, iterations int, fn func([]byte)) { panic("jsbridge") }
28
29 // Argon2idDeriveKey derives a key using Argon2id.
30 // t=time cost, m=memory KB, p=parallelism, dkLen=output bytes.
31 func Argon2idDeriveKey(password string, salt []byte, t, m, p, dkLen int, fn func([]byte)) { panic("jsbridge") }
32
33 // SHA256Hex computes SHA-256 of data via crypto.subtle and returns lowercase hex.
34 func SHA256Hex(data []byte, fn func(string)) { panic("jsbridge") }
35
36 // HMACSHA512 computes HMAC-SHA-512 via WebCrypto.
37 // Calls fn with the 64-byte MAC.
38 func HMACSHA512(key, data []byte, fn func([]byte)) { panic("jsbridge") }
39
40 // PBKDF2SHA512 derives a key using PBKDF2 with SHA-512 via WebCrypto.
41 // Calls fn with the derived key bytes.
42 func PBKDF2SHA512(password string, salt []byte, iterations, dkLen int, fn func([]byte)) { panic("jsbridge") }
43