Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,13 @@ export class CustomerMessage extends Message {

const now = new Date();

// The encryption header carries the same security profile as the
// signature: PIN version 2 for a two-step TAN method, 1 for one-step.
// Some banks (Consorsbank, BLZ 76030080) reject a two-step dialog whose
// HNVSK still says PIN:1 with "9010 Ungültiger Signaturaufbau".
const hnvsk: HNVSKSegment = {
header: { segId: HNVSK.Id, segNr: 998, version: HNVSK.Version },
secProfile: { secMethod: 'PIN', secVersion: 1 },
secProfile: { secMethod: 'PIN', secVersion: firstSignature.secProfile.secVersion },
secFunc: 998,
secRole: 1,
secId: { partyType: 1, partyId: firstSignature.secId.partyId },
Expand Down
23 changes: 23 additions & 0 deletions src/tests/message.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,27 @@ describe('CustomerMessage', () => {

const _message = Message.decode(encodedMessage);
});
it('encrypts with the security profile version of the signature (two-step: PIN:2)', () => {
const customerMessage = new CustomerMessage('0', 1);

customerMessage.addSegment(hkidn);
customerMessage.addSegment(hkvvb);
customerMessage.sign(280, '12030000', '12345678', '123', '0', 900, '12345');
const encodedMessage = customerMessage.encode();

expect(encodedMessage).toContain("'HNVSK:998:3+PIN:2+998+");
expect(encodedMessage).toContain('HNSHK:2:4+PIN:2+900+');
});

it('encrypts with the security profile version of the signature (one-step: PIN:1)', () => {
const customerMessage = new CustomerMessage('0', 1);

customerMessage.addSegment(hkidn);
customerMessage.addSegment(hkvvb);
customerMessage.sign(280, '12030000', '12345678', '123', '0');
const encodedMessage = customerMessage.encode();

expect(encodedMessage).toContain("'HNVSK:998:3+PIN:1+998+");
expect(encodedMessage).toContain('HNSHK:2:4+PIN:1+999+');
});
});