commit fd23369b92847616ca45ecff4446df2079f63001
parent 218e337a070e6b62bbf8142907c3cb8c79edc614
Author: Martin Schanzenbach <schanzen@gnunet.org>
Date: Mon, 20 Jul 2026 09:43:56 +0200
fix padding issue for mailbox messages, minor cleanups
Diffstat:
4 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/packages/taler-util/src/http-client/taldir.ts b/packages/taler-util/src/http-client/taldir.ts
@@ -214,14 +214,14 @@ export class TalerDirectoryInstanceHttpClient {
targetUri: targetUri,
duration: duration,
} = args;
- const url = new URL(`/register/${aliasType.toUpperCase()}`, this.baseUrl);
+ const url = new URL(`/register/${aliasType}`, this.baseUrl);
const resp = await this.httpLib.fetch(url.href, {
method: "POST",
body: {
alias: alias,
target_uri: targetUri,
- duration: duration,
+ duration: duration.d_us,
},
cancellationToken: this.cancellationToken,
});
diff --git a/packages/taler-util/src/taler-crypto.ts b/packages/taler-util/src/taler-crypto.ts
@@ -1934,7 +1934,7 @@ export function hpkeKeySchedule(
if (!psk) {
throw Error("Mode is PSK, but PSK not provided");
}
- if (!psk) {
+ if (!pskId) {
throw Error("Mode is PSK, but PSKID not provided");
}
} else if (mode == HpkeMode.Base) {
diff --git a/packages/taler-wallet-core/src/mailbox.ts b/packages/taler-wallet-core/src/mailbox.ts
@@ -124,7 +124,7 @@ export async function registerMailbox(
decodeCrock(mailboxConf.privateEncryptionKey),
);
// Message header: 8 byte + 64 byte SHA512 digest to sign
- // We hash ktype|key|encKtype|encKey|expiration
+ // We hash encKtype|encKey|expiration
const messageHeader = new ArrayBuffer(8);
const expNboBuffer = new ArrayBuffer(8);
const vMsg = new DataView(messageHeader);
@@ -352,23 +352,29 @@ function encryptTalerUriMessage(
talerUri: string,
paddedMessageSize: number,
): Uint8Array {
- const headerBuf = new ArrayBuffer(4);
// Padding must not include HPKE tag and encapsulation overhead
// FIXME CRYPTO-AGILITY size of tag and encapsulation depends on used algos
// DHKEM X25519: Encapsuation 32 bytes, Poly1305 tag 16 bytes
- const paddingLength = paddedMessageSize - 4 - talerUri.length - 16 - 32;
- const v = new DataView(headerBuf);
+ const talerUriBytes = stringToBytes(talerUri);
+ const paddingLength = paddedMessageSize - 4 - talerUriBytes.length - 16 - 32;
+ if (paddingLength < 0) {
+ throw new Error("talerUri is too long for the requested paddedMessageSize");
+ }
+ const header = new Uint8Array(4);
+ const v = new DataView(header.buffer);
v.setUint32(0, 0); // FIXME message type, derive number from crypto!
- const header = new Uint8Array(headerBuf);
- const padding = new Uint8Array(paddingLength).fill(0);
- const msg = new Uint8Array([...stringToBytes(talerUri), ...padding]);
+ const msg = new Uint8Array(talerUriBytes.length + paddingLength);
+ msg.set(talerUriBytes, 0);
const encryptedMessage = hpkeSealOneshot(
encryptionKey,
stringToBytes("mailbox-message"),
header,
msg,
);
- return new Uint8Array([...header, ...encryptedMessage]);
+ const result = new Uint8Array(header.length + encryptedMessage.length);
+ result.set(header, 0);
+ result.set(encryptedMessage, header.length);
+ return result;
}
export async function sendTalerUriMessage(
diff --git a/packages/taler-wallet-core/src/taldir.ts b/packages/taler-wallet-core/src/taldir.ts
@@ -115,7 +115,7 @@ export async function registerAlias(
const res = await taldirClient.postRegistrationRequest({
alias: registerRequest.alias,
aliasType: registerRequest.aliasType,
- targetUri: registerRequest.taldirBaseUrl,
+ targetUri: registerRequest.targetUri,
duration: registerRequest.duration,
});
switch (res.case) {