**Motivations:** - Consigner l'état actuel du dépôt (cron, service-login-verify, website-skeleton, userwallet, docs). - Centraliser les modifications en attente. **Root causes:** - N/A (commit groupé). **Correctifs:** - N/A. **Evolutions:** - Cron quotidien restart services : script local sans SSH, systemd (bitcoin-signet, bitcoin, APIs, dashboard, userwallet, website-skeleton) + Docker (mempool, bitcoin-signet-instance). - Feature cron-restart-services-local : documentation et règle scripts locaux / pas d'SSH. - service-login-verify : module vérification login (buildAllowedPubkeys, verifyLoginProof, nonceCache). - website-skeleton : app iframe UserWallet, config, systemd unit. - userwallet : collectSignatures, relay. - docs : DOMAINS_AND_PORTS, README, WEBSITE_SKELETON ; features userwallet-contrat-login, timeouts-backoff, service-login-verify. **Pages affectées:** - data/restart-services-cron.sh, data/restart-services.log, data/sync-utxos.log - features/cron-restart-services-local.md, features/service-login-verify.md, features/userwallet-contrat-login-reste-a-faire.md, features/userwallet-timeouts-backoff.md - docs/DOMAINS_AND_PORTS.md, docs/README.md, docs/WEBSITE_SKELETON.md - configure-nginx-proxy.sh - service-login-verify/ (src, dist, node_modules) - userwallet/src/utils/collectSignatures.ts, userwallet/src/utils/relay.ts - website-skeleton/
91 lines
3.1 KiB
JavaScript
91 lines
3.1 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.hmac = exports.HMAC = void 0;
|
|
/**
|
|
* HMAC: RFC2104 message authentication code.
|
|
* @module
|
|
*/
|
|
const utils_ts_1 = require("./utils.js");
|
|
class HMAC extends utils_ts_1.Hash {
|
|
constructor(hash, _key) {
|
|
super();
|
|
this.finished = false;
|
|
this.destroyed = false;
|
|
(0, utils_ts_1.ahash)(hash);
|
|
const key = (0, utils_ts_1.toBytes)(_key);
|
|
this.iHash = hash.create();
|
|
if (typeof this.iHash.update !== 'function')
|
|
throw new Error('Expected instance of class which extends utils.Hash');
|
|
this.blockLen = this.iHash.blockLen;
|
|
this.outputLen = this.iHash.outputLen;
|
|
const blockLen = this.blockLen;
|
|
const pad = new Uint8Array(blockLen);
|
|
// blockLen can be bigger than outputLen
|
|
pad.set(key.length > blockLen ? hash.create().update(key).digest() : key);
|
|
for (let i = 0; i < pad.length; i++)
|
|
pad[i] ^= 0x36;
|
|
this.iHash.update(pad);
|
|
// By doing update (processing of first block) of outer hash here we can re-use it between multiple calls via clone
|
|
this.oHash = hash.create();
|
|
// Undo internal XOR && apply outer XOR
|
|
for (let i = 0; i < pad.length; i++)
|
|
pad[i] ^= 0x36 ^ 0x5c;
|
|
this.oHash.update(pad);
|
|
(0, utils_ts_1.clean)(pad);
|
|
}
|
|
update(buf) {
|
|
(0, utils_ts_1.aexists)(this);
|
|
this.iHash.update(buf);
|
|
return this;
|
|
}
|
|
digestInto(out) {
|
|
(0, utils_ts_1.aexists)(this);
|
|
(0, utils_ts_1.abytes)(out, this.outputLen);
|
|
this.finished = true;
|
|
this.iHash.digestInto(out);
|
|
this.oHash.update(out);
|
|
this.oHash.digestInto(out);
|
|
this.destroy();
|
|
}
|
|
digest() {
|
|
const out = new Uint8Array(this.oHash.outputLen);
|
|
this.digestInto(out);
|
|
return out;
|
|
}
|
|
_cloneInto(to) {
|
|
// Create new instance without calling constructor since key already in state and we don't know it.
|
|
to || (to = Object.create(Object.getPrototypeOf(this), {}));
|
|
const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;
|
|
to = to;
|
|
to.finished = finished;
|
|
to.destroyed = destroyed;
|
|
to.blockLen = blockLen;
|
|
to.outputLen = outputLen;
|
|
to.oHash = oHash._cloneInto(to.oHash);
|
|
to.iHash = iHash._cloneInto(to.iHash);
|
|
return to;
|
|
}
|
|
clone() {
|
|
return this._cloneInto();
|
|
}
|
|
destroy() {
|
|
this.destroyed = true;
|
|
this.oHash.destroy();
|
|
this.iHash.destroy();
|
|
}
|
|
}
|
|
exports.HMAC = HMAC;
|
|
/**
|
|
* HMAC: RFC2104 message authentication code.
|
|
* @param hash - function that would be used e.g. sha256
|
|
* @param key - message key
|
|
* @param message - message data
|
|
* @example
|
|
* import { hmac } from '@noble/hashes/hmac';
|
|
* import { sha256 } from '@noble/hashes/sha2';
|
|
* const mac1 = hmac(sha256, 'key', 'message');
|
|
*/
|
|
const hmac = (hash, key, message) => new HMAC(hash, key).update(message).digest();
|
|
exports.hmac = hmac;
|
|
exports.hmac.create = (hash, key) => new HMAC(hash, key);
|
|
//# sourceMappingURL=hmac.js.map
|