aegis-aead 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +0 -6
  2. package/README.md~ +154 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -144,12 +144,6 @@ open examples/index.html
144
144
 
145
145
  The example demonstrates encryption/decryption with a simple UI where you can enter a message, encrypt it, and decrypt it back.
146
146
 
147
- ## Security Notes
148
-
149
- - Never reuse a nonce with the same key
150
- - Decryption returns `null` on authentication failure; do not use any partial output
151
- - Tag verification uses constant-time comparison
152
-
153
147
  ## License
154
148
 
155
149
  MIT
package/README.md~ ADDED
@@ -0,0 +1,154 @@
1
+ # aegis-aead
2
+
3
+ [![npm](https://img.shields.io/npm/v/aegis-aead)](https://www.npmjs.com/package/aegis-aead)
4
+ [![CI](https://github.com/jedisct1/js-aegis-aead/actions/workflows/ci.yml/badge.svg)](https://github.com/jedisct1/js-aegis-aead/actions/workflows/ci.yml)
5
+
6
+ JavaScript / TypeScript implementation of the [AEGIS authenticated encryption algorithms](https://datatracker.ietf.org/doc/draft-irtf-cfrg-aegis-aead/).
7
+
8
+ AEGIS is a family of fast authenticated encryption algorithms built on AES round functions. It provides both encryption with authentication and standalone MAC functionality.
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ bun add aegis-aead
14
+ # or
15
+ npm install aegis-aead
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ ### Encryption and Decryption
21
+
22
+ ```typescript
23
+ import { aegis128LEncrypt, aegis128LDecrypt } from "aegis-aead";
24
+
25
+ const key = crypto.getRandomValues(new Uint8Array(16));
26
+ const nonce = crypto.getRandomValues(new Uint8Array(16));
27
+ const message = new TextEncoder().encode("Hello, world!");
28
+ const associatedData = new TextEncoder().encode("metadata");
29
+
30
+ // Encrypt
31
+ const { ciphertext, tag } = aegis128LEncrypt(message, associatedData, key, nonce);
32
+
33
+ // Decrypt (returns null if authentication fails)
34
+ const decrypted = aegis128LDecrypt(ciphertext, tag, associatedData, key, nonce);
35
+ ```
36
+
37
+ ### MAC (Message Authentication Code)
38
+
39
+ ```typescript
40
+ import { aegis128LMac, aegis128LMacVerify } from "aegis-aead";
41
+
42
+ const key = crypto.getRandomValues(new Uint8Array(16));
43
+ const nonce = crypto.getRandomValues(new Uint8Array(16));
44
+ const data = new TextEncoder().encode("data to authenticate");
45
+
46
+ // Generate MAC
47
+ const tag = aegis128LMac(data, key, nonce);
48
+
49
+ // Verify MAC
50
+ const valid = aegis128LMacVerify(data, tag, key, nonce);
51
+ ```
52
+
53
+ ## Algorithms
54
+
55
+ | Algorithm | Key Size | Nonce Size | Block Size | Use Case |
56
+ | ---------- | -------- | ---------- | ---------- | ---------------------------------- |
57
+ | AEGIS-128L | 16 bytes | 16 bytes | 32 bytes | High throughput on 64-bit CPUs |
58
+ | AEGIS-256 | 32 bytes | 32 bytes | 16 bytes | 256-bit security level |
59
+ | AEGIS-128X | 16 bytes | 16 bytes | 32×D bytes | Multi-lane AEGIS-128L (D = degree) |
60
+ | AEGIS-256X | 32 bytes | 32 bytes | 16×D bytes | Multi-lane AEGIS-256 (D = degree) |
61
+
62
+ ### Tag Lengths
63
+
64
+ All algorithms support two tag lengths:
65
+ - 16 bytes (128-bit) - default
66
+ - 32 bytes (256-bit) - pass `32` as the last parameter to encrypt/MAC functions
67
+
68
+ ## API Reference
69
+
70
+ ### AEGIS-128L
71
+
72
+ ```typescript
73
+ aegis128LEncrypt(msg, ad, key, nonce, tagLen?): { ciphertext, tag }
74
+ aegis128LDecrypt(ciphertext, tag, ad, key, nonce): Uint8Array | null
75
+ aegis128LMac(data, key, nonce, tagLen?): Uint8Array
76
+ aegis128LMacVerify(data, tag, key, nonce): boolean
77
+ ```
78
+
79
+ ### AEGIS-256
80
+
81
+ ```typescript
82
+ aegis256Encrypt(msg, ad, key, nonce, tagLen?): { ciphertext, tag }
83
+ aegis256Decrypt(ciphertext, tag, ad, key, nonce): Uint8Array | null
84
+ aegis256Mac(data, key, nonce, tagLen?): Uint8Array
85
+ aegis256MacVerify(data, tag, key, nonce): boolean
86
+ ```
87
+
88
+ ### AEGIS-128X
89
+
90
+ Pre-configured variants for degree 2 and 4:
91
+
92
+ ```typescript
93
+ // Degree 2
94
+ aegis128X2Encrypt(msg, ad, key, nonce, tagLen?): { ciphertext, tag }
95
+ aegis128X2Decrypt(ciphertext, tag, ad, key, nonce): Uint8Array | null
96
+ aegis128X2Mac(data, key, nonce, tagLen?): Uint8Array
97
+ aegis128X2MacVerify(data, tag, key, nonce): boolean
98
+
99
+ // Degree 4
100
+ aegis128X4Encrypt(msg, ad, key, nonce, tagLen?): { ciphertext, tag }
101
+ aegis128X4Decrypt(ciphertext, tag, ad, key, nonce): Uint8Array | null
102
+ aegis128X4Mac(data, key, nonce, tagLen?): Uint8Array
103
+ aegis128X4MacVerify(data, tag, key, nonce): boolean
104
+
105
+ // Custom degree
106
+ aegis128XEncrypt(msg, ad, key, nonce, tagLen?, degree?): { ciphertext, tag }
107
+ aegis128XDecrypt(ciphertext, tag, ad, key, nonce, degree?): Uint8Array | null
108
+ aegis128XMac(data, key, nonce, tagLen?, degree?): Uint8Array
109
+ aegis128XMacVerify(data, tag, key, nonce, degree?): boolean
110
+ ```
111
+
112
+ ### AEGIS-256X
113
+
114
+ Pre-configured variants for degree 2 and 4:
115
+
116
+ ```typescript
117
+ // Degree 2
118
+ aegis256X2Encrypt(msg, ad, key, nonce, tagLen?): { ciphertext, tag }
119
+ aegis256X2Decrypt(ciphertext, tag, ad, key, nonce): Uint8Array | null
120
+ aegis256X2Mac(data, key, nonce, tagLen?): Uint8Array
121
+ aegis256X2MacVerify(data, tag, key, nonce): boolean
122
+
123
+ // Degree 4
124
+ aegis256X4Encrypt(msg, ad, key, nonce, tagLen?): { ciphertext, tag }
125
+ aegis256X4Decrypt(ciphertext, tag, ad, key, nonce): Uint8Array | null
126
+ aegis256X4Mac(data, key, nonce, tagLen?): Uint8Array
127
+ aegis256X4MacVerify(data, tag, key, nonce): boolean
128
+
129
+ // Custom degree
130
+ aegis256XEncrypt(msg, ad, key, nonce, tagLen?, degree?): { ciphertext, tag }
131
+ aegis256XDecrypt(ciphertext, tag, ad, key, nonce, degree?): Uint8Array | null
132
+ aegis256XMac(data, key, nonce, tagLen?, degree?): Uint8Array
133
+ aegis256XMacVerify(data, tag, key, nonce, degree?): boolean
134
+ ```
135
+
136
+ ## Browser Example
137
+
138
+ A browser example is included in `examples/`. To build and run it:
139
+
140
+ ```bash
141
+ bun run build:example
142
+ open examples/index.html
143
+ ```
144
+
145
+ The example demonstrates encryption/decryption with a simple UI where you can enter a message, encrypt it, and decrypt it back.
146
+
147
+ ## Security Notes
148
+
149
+ - Never reuse a nonce with the same key
150
+ - Decryption returns `null` on authentication failure; do not use any partial output
151
+
152
+ ## License
153
+
154
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aegis-aead",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "AEGIS authenticated encryption algorithms",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",