-
Notifications
You must be signed in to change notification settings - Fork 6
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
8 changed files
with
68 additions
and
28 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
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
4 changes: 2 additions & 2 deletions
4
src/connector/helpers/derive-secrets-from-connection-password.ts
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,7 @@ | ||
import { sha256 } from 'crypto/sha256' | ||
import { blake2b } from 'crypto/blake2b' | ||
|
||
export const deriveSecretsFromPassword = (password: Buffer) => | ||
sha256(password).map((connectionId) => ({ | ||
blake2b(password).map((connectionId) => ({ | ||
connectionId, | ||
encryptionKey: password, | ||
})) |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { blake2b } from './blake2b' | ||
import { Buffer } from 'buffer' | ||
|
||
describe('blake2b', () => { | ||
it('should hash a string', async () => { | ||
const result = await blake2b(Buffer.from('test')) | ||
|
||
if (result.isErr()) throw result.error | ||
|
||
expect(result.value.toString('hex')).toBe( | ||
'928b20366943e2afd11ebc0eae2e53a93bf177a4fcf35bcc64d503704e65e202' | ||
) | ||
}) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Buffer } from 'buffer' | ||
import blake2bHash from 'blake2b' | ||
import { errAsync, okAsync, ResultAsync } from 'neverthrow' | ||
|
||
export const blake2b = (input: Buffer): ResultAsync<Buffer, Error> => { | ||
const output = new Uint8Array(32) | ||
try { | ||
return okAsync( | ||
blake2bHash(output.length).update(new Uint8Array(input)).digest('hex') | ||
).map((hex) => Buffer.from(hex, 'hex')) | ||
} catch (error) { | ||
return errAsync(error as Error) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
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