HkdfSecretKey class abstract

HKDF secret key (or password) for key derivation.

An HkdfSecretKey instance holds a secret key for key derivation using the HMAC-based Key Derivation Function specified in RFC 5869 using a Hash function specified in the deriveBits method.

A HkdfSecretKey can be imported using importRawKey.

Example

import 'dart:convert' show utf8, base64;
import 'package:webcrypto/webcrypto.dart';

// Provide a password to be used for key derivation
final key = await HkdfSecretKey.importRawKey(utf8.decode(
  'my-password-in-plain-text',
));

// Derive a key from password
final derivedKey = await HkdfSecretKey.deriveBits(
  256, // number of bits to derive.
  Hash.sha256,
  utf8.decode('unique salt'),
  utf8.decode('creating derivedKey in example'),
);

// Print the derived key, this could also be used as basis for other new
// symmetric cryptographic keys.
print(base64.encode(derivedKey));
Annotations
  • @sealed

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

deriveBits(int length, Hash hash, List<int> salt, List<int> info) Future<Uint8List>
Derive key from salt, info and password specified as keyData in importRawKey.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

importRawKey(List<int> keyData) Future<HkdfSecretKey>
Import HkdfSecretKey from raw keyData.