* Create a complete R6 (AES-256) encryption setup for testing.
( userPassword: string, ownerPassword: string, permissions: Permissions = DEFAULT_PERMISSIONS, )
| 117 | * Create a complete R6 (AES-256) encryption setup for testing. |
| 118 | */ |
| 119 | function createR6Setup( |
| 120 | userPassword: string, |
| 121 | ownerPassword: string, |
| 122 | permissions: Permissions = DEFAULT_PERMISSIONS, |
| 123 | ) { |
| 124 | const userPwd = new TextEncoder().encode(userPassword); |
| 125 | const ownerPwd = new TextEncoder().encode(ownerPassword); |
| 126 | const fileId = new Uint8Array(32); |
| 127 | |
| 128 | for (let i = 0; i < 32; i++) { |
| 129 | fileId[i] = i; |
| 130 | } |
| 131 | |
| 132 | const permissionsRaw = encodePermissions(permissions); |
| 133 | |
| 134 | // Generate a random 256-bit file key |
| 135 | const fileKey = new Uint8Array(32); |
| 136 | |
| 137 | for (let i = 0; i < 32; i++) { |
| 138 | fileKey[i] = (i * 17) % 256; |
| 139 | } |
| 140 | |
| 141 | const revision = 6; |
| 142 | |
| 143 | // Generate encryption dictionary entries |
| 144 | const { u: userHash, ue: userEncryptionKey } = generateUserEntries(userPwd, fileKey, revision); |
| 145 | const { o: ownerHash, oe: ownerEncryptionKey } = generateOwnerEntries( |
| 146 | ownerPwd, |
| 147 | fileKey, |
| 148 | userHash, |
| 149 | revision, |
| 150 | ); |
| 151 | const permsValue = generatePermsEntry(fileKey, permissionsRaw, true); |
| 152 | |
| 153 | const encryptDict: EncryptionDict = { |
| 154 | filter: "Standard", |
| 155 | version: 5, |
| 156 | revision: 6, |
| 157 | keyLengthBits: 256, |
| 158 | ownerHash, |
| 159 | userHash, |
| 160 | permissions, |
| 161 | permissionsRaw, |
| 162 | encryptMetadata: true, |
| 163 | ownerEncryptionKey, |
| 164 | userEncryptionKey, |
| 165 | permsValue, |
| 166 | algorithm: "AES-256", |
| 167 | }; |
| 168 | |
| 169 | return { encryptDict, fileId, fileKey, userPwd, ownerPwd }; |
| 170 | } |
| 171 | |
| 172 | describe("StandardSecurityHandler", () => { |
| 173 | describe("R3 (RC4-128)", () => { |
no test coverage detected