File tree Expand file tree Collapse file tree 4 files changed +48
-9
lines changed Expand file tree Collapse file tree 4 files changed +48
-9
lines changed Original file line number Diff line number Diff line change
1
+ import { Digest } from "./Digest"
2
+ /**
3
+ * A HMAC ( commonly referred to as a Hash ) (hash-based message authentication
4
+ * code) is a type of message authentication code (MAC) that uses a
5
+ * cryptographic hash function and a secret key. It may be used to verify data
6
+ * integrity and authentication of a message.
7
+ *
8
+ * Strontium assumes that HMAC functions will run on input that is entirely
9
+ * in memory. The interface does not currently support calculations against a
10
+ * stream.
11
+ *
12
+ * The exact nature or security properties of a given HMAC implementation
13
+ * will vary based on the implementing class.
14
+ */
15
+ export abstract class HMAC extends Digest {
16
+ /**
17
+ * Create a new HMAC Encrypter.
18
+ *
19
+ * @param secretKey - The shared secret to use for encryption.
20
+ */
21
+ constructor ( protected secretKey : Buffer ) {
22
+ super ( )
23
+ }
24
+ }
Original file line number Diff line number Diff line change
1
+ import { HMAC } from "../../abstract/HMAC"
2
+ import { createHmac } from "crypto"
3
+
4
+ /**
5
+ * The SHA1HMAC provides a HMAC implementation using SHA1 based on Node's
6
+ * OpenSSL.
7
+ *
8
+ * This implementation relies on the node crypto implementation and may vary based
9
+ * on the build flags of the underlying runtime.
10
+ */
11
+ export class SHA1HMAC extends HMAC {
12
+ public async calculate ( input : Buffer ) : Promise < Buffer > {
13
+ let hmacBuilder = createHmac ( "sha1" , this . secretKey )
14
+ hmacBuilder . update ( input )
15
+
16
+ return hmacBuilder . digest ( )
17
+ }
18
+ }
Original file line number Diff line number Diff line change 1
1
export { AsymmetricSigner } from "./abstract/AsymmetricSigner"
2
2
export { Digest } from "./abstract/Digest"
3
+ export { HMAC } from "./abstract/HMAC"
3
4
export { JWTSigner } from "./abstract/JWTSigner"
4
5
export { MessageAuthenticationCode } from "./abstract/MessageAuthenticationCode"
5
6
export { SymmetricEncrypter } from "./abstract/SymmetricEncrypter"
6
7
7
8
export { AsymmetricJWTSigner } from "./drivers/node/AsymmetricJWTSigner"
8
9
export { RSASHA256Signer } from "./drivers/node/RSASHA256Signer"
9
10
export { SHA256Digest } from "./drivers/node/SHA256Digest"
11
+ export { SHA1HMAC } from "./drivers/node/SHA1HMAC"
You can’t perform that action at this time.
0 commit comments