-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
97 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,67 @@ | ||
/** | ||
* Size (in bytes) of salt block in encryption content-coding header. | ||
*/ | ||
export const SALT_LENGTH = 16; | ||
/** | ||
* Size (in bytes) of record size block in encryption content-coding header. | ||
*/ | ||
export const RS_LENGTH = 4; | ||
|
||
/** | ||
* Size (in bytes) of idlen block in encryption content-coding header. | ||
*/ | ||
export const IDLEN_LENGTH = 1; | ||
|
||
/** | ||
* Size (in bytes) of content-encryption key. | ||
*/ | ||
export const KEY_LENGTH = 16; | ||
|
||
/** | ||
* Size of authentication tag block in encryption content-coding header. | ||
*/ | ||
export const TAG_LENGTH = 16; | ||
|
||
/** | ||
* Size of a nonce. | ||
*/ | ||
export const NONCE_LENGTH = 12; | ||
|
||
/** | ||
* Minimum size of an encryption content-coding header. | ||
*/ | ||
export const HEADER_LENGTH_MIN = SALT_LENGTH + RS_LENGTH + IDLEN_LENGTH; | ||
|
||
/** | ||
* Default size of a record. | ||
*/ | ||
export const DEFAULT_RECORD_SIZE = 1024 * 64; | ||
/** | ||
* Minimum size of a record. | ||
*/ | ||
export const RECORD_SIZE_MIN = 18; | ||
/** | ||
* Maximum size of a record. | ||
*/ | ||
export const RECORD_SIZE_MAX = 2 ** 36 - 31; | ||
|
||
export const encoder: TextEncoder = new TextEncoder(); | ||
const encoder: TextEncoder = new TextEncoder(); | ||
|
||
/** | ||
* Content-encryption key info as in https://www.rfc-editor.org/rfc/rfc8188#section-2.2 | ||
*/ | ||
export const CEK_INFO: Uint8Array = encoder.encode( | ||
"Content-Encoding: aes128gcm\0", | ||
); | ||
|
||
/** | ||
* Nonce info as in https://www.rfc-editor.org/rfc/rfc8188#section-2.3 | ||
*/ | ||
export const NONCE_INFO: Uint8Array = encoder.encode( | ||
"Content-Encoding: nonce\0", | ||
); | ||
/** | ||
* Uint8Array of size 1 containing a single byte of value 1. | ||
* This is mostly used for concatenation with others Uint8Array. | ||
*/ | ||
export const ONE_BYTE: Uint8Array = encoder.encode("\x01"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
export { decrypt, encrypt, WithPaddingRecordIterable } from "./ece.ts"; | ||
export { Header } from "./header.ts"; | ||
export type { HeaderOptions } from "./header.ts"; | ||
export { Salt } from "./salt.ts"; | ||
export { ECECrypto } from "./ece_crypto.ts"; | ||
export type { ECECryptoOptions } from "./ece_crypto.ts"; | ||
export * from "./ece.ts"; | ||
export * from "./header.ts"; | ||
export * from "./salt.ts"; | ||
export * from "./ece_crypto.ts"; | ||
export * from "./const.ts"; |