Skip to content

Commit

Permalink
Move static buffers into getters to avoid side-effects
Browse files Browse the repository at this point in the history
  • Loading branch information
corrideat committed Feb 9, 2024
1 parent 7223a2a commit c1cafaf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@exact-realty/rfc8188",
"version": "1.0.1",
"version": "1.0.2",
"description": "An implementation of RFC 8188 (encrypted content-encoding for HTTP)",
"type": "module",
"main": "dist/index.cjs",
Expand Down
46 changes: 28 additions & 18 deletions src/encodings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,21 @@ export const aes128gcm: Readonly<TEncoding> = {
['length']: 128,
},
// The literal `Content-Encoding: aes128gcm\x00`
cek_info: new Uint8Array([
0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x45, 0x6e, 0x63, 0x6f,
0x64, 0x69, 0x6e, 0x67, 0x3a, 0x20, 0x61, 0x65, 0x73, 0x31, 0x32, 0x38,
0x67, 0x63, 0x6d, 0x00,
]),
get cek_info() {
return new Uint8Array([
0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x45, 0x6e, 0x63,
0x6f, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x20, 0x61, 0x65, 0x73, 0x31,
0x32, 0x38, 0x67, 0x63, 0x6d, 0x00,
]);
},
// The literal `Content-Encoding: nonce\x00`
nonce_info: new Uint8Array([
0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x45, 0x6e, 0x63, 0x6f,
0x64, 0x69, 0x6e, 0x67, 0x3a, 0x20, 0x6e, 0x6f, 0x6e, 0x63, 0x65, 0x00,
]),
get nonce_info() {
return new Uint8Array([
0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x45, 0x6e, 0x63,
0x6f, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x20, 0x6e, 0x6f, 0x6e, 0x63,
0x65, 0x00,
]);
},
block_size: 16,
tag_length: 16,
nonce_length: 12,
Expand All @@ -50,16 +55,21 @@ export const aes256gcm: Readonly<TEncoding> = {
['length']: 256,
},
// The literal `Content-Encoding: aes256gcm\x00`
cek_info: new Uint8Array([
0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x45, 0x6e, 0x63, 0x6f,
0x64, 0x69, 0x6e, 0x67, 0x3a, 0x20, 0x61, 0x65, 0x73, 0x32, 0x35, 0x36,
0x67, 0x63, 0x6d, 0x00,
]),
get cek_info() {
return new Uint8Array([
0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x45, 0x6e, 0x63,
0x6f, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x20, 0x61, 0x65, 0x73, 0x32,
0x35, 0x36, 0x67, 0x63, 0x6d, 0x00,
]);
},
// The literal `Content-Encoding: nonce\x00`
nonce_info: new Uint8Array([
0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x45, 0x6e, 0x63, 0x6f,
0x64, 0x69, 0x6e, 0x67, 0x3a, 0x20, 0x6e, 0x6f, 0x6e, 0x63, 0x65, 0x00,
]),
get nonce_info() {
return new Uint8Array([
0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x45, 0x6e, 0x63,
0x6f, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x20, 0x6e, 0x6f, 0x6e, 0x63,
0x65, 0x00,
]);
},
block_size: 16,
tag_length: 16,
nonce_length: 12,
Expand Down

0 comments on commit c1cafaf

Please sign in to comment.