Skip to content

TWebHMACSignature

TWebHMACSignature is a wrapper around the Web Crypto API. It's recommended to first familiarize yourself with the Web Crypto API: https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API

The Web Crypto API provides native support to create, use and store cryptographic keys without exposing the content of private keys.

See TWebAESEncryption documentation on how to create keys. See TWebRSASignature documentation on signing and verifying data.

Below is a list of the most important properties, methods and events for the TWebHMACSignature class.

Properties for TWebHMACSignature

Property Description
CryptoKey: TJSCryptoKey The CryptoKey object.
ExtractableKey: Boolean Determines if the key is extractable. If modified, it's not applied to the current key.
Hash: TCryptoHash The hash function to be used with the algorithm. If modified, it's not applied to the current key.
Usages Set of key usages. If modified, it's not applied to the current key.

Methods for TWebHMACSignature

Property Description
ExportKey(AFormat: TCryptoExportImportFormat) Method to export the class's key. Supported formats are: raw (ArrayBuffer) and jwk (JSON string).
ExportKeyP(AFormat: TCryptoExportImportFormat): TJSPromise Promise-based equivalent of ExportKey. Resolves with a TJSUint8Array value if AFormat = efRaw. Resolves with string if AFormat = efJSON.
GenerateKey Generates a new key based on the current property settings.
GenerateKeyP: TJSPromise Promise-based equivalent of GenerateKey. Resolves with a True value.
ImportKey(AJSON: string) Method to import a HMAC key that is stored as a JSON string.
ImportKey(ABinary: TJSUint8Array) Method to import a HMAC key that is stored as binary data.
ImportKeyP(ABinary: TJSUint8Array): TJSPromise Promise-based equivalent of ImportKey(ABinary). Resolves with a True value.
ImportKey(ARaw: TJSArrayBuffer) Method to import a HMAC key that is stored as an array buffer.
ImportKeyP(ARaw: TJSArrayBuffer): TJSPromise
Sign(AText: string) Sign AText with the class's public key and algorithm.
SignP(AText: string): TJSPromise Promise-based equivalent of Sign(AText). Resolves with a TJSArrayBuffer value.
Sign(ABinary: TJSUint8Array) Sign ABinary with the class's public key and algorithm.
SignP(ABinary: TJSUint8Array): TJSPromise Promise-based equivalent of Sign(ABinary). Resolves with a TJSArrayBuffer value.
Verify(ASignature: TJSArrayBuffer; AData: TJSArrayBuffer) Verify AData with ASignature, using the class's private key and algorithm.
VerifyP(ASignature: TJSArrayBuffer; AData: TJSArrayBuffer): TJSPromise Promise-based equivalent of Verify. Resolves with a Boolean value.

Events for TWebHMACSignature

Property Description
OnError Event triggered when there's a Promise rejection.
OnKeyCreated Event triggered when a key is created.
OnKeyExportedJSON Event triggered when a key is exported as a JSON string.
OnKeyExportedRaw Event triggered when a key is exported as an array buffer.
OnKeyImported Event triggered when a key is imported.
OnSigned Event triggered when data is signed.
OnVerify Event triggered when data is verified