Skip to content

Commit

Permalink
Use byteSwapIfBE when copying to out32 in digestInto
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-albrecht-ibm committed Feb 7, 2024
1 parent c03a557 commit 4beb199
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/_blake.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { number, exists, output } from './_assert.js';
import { Hash, Input, toBytes, u32, isLE, byteSwap, byteSwap32 } from './utils.js';
import { Hash, Input, toBytes, u32, isLE, byteSwap32, byteSwapIfBE } from './utils.js';

// Blake is based on ChaCha permutation.

Expand Down Expand Up @@ -110,7 +110,7 @@ export abstract class BLAKE<T extends BLAKE<T>> extends Hash<T> {
this.compress(buffer32, 0, true);
if (!isLE) byteSwap32(buffer32);
const out32 = u32(out);
this.get().forEach(isLE ? (v, i) => (out32[i] = v) : (v, i) => (out32[i] = byteSwap(v)));
this.get().forEach((v, i) => (out32[i] = byteSwapIfBE(v)));
}
digest() {
const { buffer, outputLen } = this;
Expand Down

0 comments on commit 4beb199

Please sign in to comment.