Single-Step Key Derivation function following NIST SP 800-56C revision 1, chapter 4 in TypeScript/JavaScript fully compatible with NodeJS.
Add dependency to your proyect:
- Yarn:
yarn add single-step-kdf-nist
- npm:
npm i single-step-kdf-nist
Simple example:
import { singleStepKDF, hexToBytes, bytesToHex } from "single-step-kdf";
const hexSingleStepKDF = () => {
const sharedSecretString = "test";
const sharedSecret: Uint8Array = hexToBytes(sharedSecretString);
const fixedInfo = JSON.stringify({ info: "some info" });
const kdf = singleStepKDF(
"sha256",
sharedSecret,
32,
hexToBytes(fixedInfo)
);
return bytesToHex(kdf).toUpperCase();
};
Use yarn to build the project.
yarn build
yarn test
Implement different H-Functions:
- Message digest.
- HMAC.
- KMAC.
Others:
- Improve README.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.