File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55 * @author Chris Breuer
66 */
77
8- import { md } from './md'
8+ import { mgf1 } from './mgf1'
9+ import { sha1 } from './algorithms/hash/sha1'
910
10- export const mgf = {
11- mgf1 : md . sha1 . create ( ) . update ( 'sha1' ) . digest ( ) ,
11+ export interface MGF {
12+ mgf1 : ( seed : string , maskLen : number ) => string
13+ }
14+
15+ export const mgf : MGF = {
16+ mgf1 : ( seed : string , maskLen : number ) => mgf1 . create ( sha1 . create ( ) ) . generate ( seed , maskLen )
1217}
Original file line number Diff line number Diff line change 66 * @author Chris Breuer
77 */
88
9- import { ByteBuffer } from './utils'
9+ import { ByteBuffer , ByteStringBuffer } from './utils'
1010
1111interface MessageDigest {
1212 start : ( ) => void
13- update : ( data : string ) => void
14- digest : ( ) => string
13+ update : ( data : string | ByteStringBuffer ) => void
14+ digest : ( ) => ByteStringBuffer
1515 digestLength : number
1616}
1717
@@ -44,7 +44,7 @@ export function create(md: MessageDigest) {
4444 // b. Concatenate the hash of the seed mgfSeed and C to the octet string T:
4545 md . start ( )
4646 md . update ( seed + c . getBytes ( ) )
47- t . putBuffer ( md . digest ( ) )
47+ t . putBuffer ( new ByteBuffer ( md . digest ( ) . getBytes ( ) ) )
4848 }
4949
5050 // output the leading maskLen octets of T as the octet string mask
@@ -54,8 +54,8 @@ export function create(md: MessageDigest) {
5454 }
5555
5656 return {
57- generate,
58- }
57+ generate : generate
58+ } as { generate : ( seed : string , maskLen : number ) => string }
5959}
6060
6161export interface MGF1 {
You can’t perform that action at this time.
0 commit comments