Skip to content

Commit e911c10

Browse files
authored
Fix subkey_multiple_sigs.iced test file (#229)
That file had a hardcoded public key chunks that end up creating a subkey with expiration time that was long in the past now in 2025.
1 parent fbb6084 commit e911c10

File tree

1 file changed

+31
-30
lines changed

1 file changed

+31
-30
lines changed

test/files/subkey_multiple_sigs.iced

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ encryptSigPacket = 'c2610418130a001305025b6f14260910433b1545547b718c021b0c000013
2525
encryptXSignPacket = 'c2c01b0418130a001905025b6f14260910433b1545547b718c021b0c05090784ce00007473200419010a000605025b6f14260000863803006e73fb2763cb717761b4c8cda9306037c58715454f92d4c39004cf7adffdfc25ea79b85d65840a13bb8eb1d8db455a2f72207195aeed8f6a37e6dfcd35ef5985de539f3bf17358841ad7581fc2cb5844dbb0b2d206e6ae6e99447fcb7f930651f00200ff785d955a6c2a10bded5f7033ba6fa9b38b58dcbf17039bf593fd060a4735e3ef00fd12376c99eb14665d8620c90debc5993be492dbb163e9bc364d52b2b8acc11c68'
2626

2727
# Signature with Flags=Sign, not cross-certified. Provides no-expiration for the,
28-
# so it would win against encryptXSignPacket.
28+
# so it would win against encryptXSignPacket.
2929
signSigNoXSignPacket = 'c2610418130a001305025b6f14260910433b1545547b718c021b020000ca2f00ff7c5d366c584ca03ea27cd0dad841f8adda24fc7efa212550ec773effc418136300fe32160c17b36a3a13be3ca6058d35dc7da89bfbb857753e6db45994183e58ed6d'
3030

3131
armoredMessage = """
@@ -40,10 +40,13 @@ xC/ywM5zfa/WOMD1zrOjoCpUktnyMZN8H4P4bF8Az4aj
4040
4141
"""
4242

43+
testing_unixtime = 1534006310
44+
4345
make_key_from_parts = (parts, cb) ->
4446
keyBuf = Buffer.from(parts.join(''), 'hex')
4547
msg = new Message { body : keyBuf, type : C.message_types.public_key }
46-
KeyManager.import_from_pgp_message { msg }, cb
48+
opts = { now : testing_unixtime }
49+
KeyManager.import_from_pgp_message { msg, opts }, cb
4750

4851
exports.load_multi_binding_key_and_verify = (T, cb) ->
4952
esc = make_esc cb, "load_multi_binding_key_and_verify"
@@ -55,35 +58,33 @@ exports.load_multi_binding_key_and_verify = (T, cb) ->
5558
cb null
5659

5760
exports.load_with_only_right_sig_then_verify = (T, cb) ->
61+
esc = make_esc cb, "load_with_only_right_sig_then_verify"
62+
# Only concat flagSignSig - if we don't add encryptSig, it won't
63+
# "win over" signSig, so this key will actually function as a
64+
# signing subkey.
65+
await make_key_from_parts [keyAndIdsPackets, subkeyPacket, signSigPacket], esc defer km
66+
now = testing_unixtime
67+
await do_message { armored : armoredMessage, keyfetch : km, now }, defer err, msg
68+
T.assert not(err?), "no error #{err}"
69+
T.assert (msg?[0]?.get_data_signer()?), "was signed!"
70+
T.equal msg?[0]?.data.toString(), "hello cross signed world", "right message came back"
71+
5872
cb null
59-
# FIXME
60-
# esc = make_esc cb, "load_with_only_right_sig_then_verify"
61-
# # Only concat flagSignSig - if we don't add encryptSig, it won't
62-
# # "win over" signSig, so this key will actually function as a
63-
# # signing subkey.
64-
# await make_key_from_parts [keyAndIdsPackets, subkeyPacket, signSigPacket], esc defer km
65-
# await do_message { armored : armoredMessage, keyfetch : km }, defer err, msg
66-
# T.assert not(err?), "no error #{err}"
67-
# T.assert (msg?[0]?.get_data_signer()?), "was signed!"
68-
# T.equal msg?[0]?.data.toString(), "hello cross signed world", "right message came back"
6973

70-
# cb null
71-
7274
exports.do_not_merge_crosscertify = (T, cb) ->
75+
esc = make_esc cb, "do_not_merge_crosscertify"
76+
# Pass two bindings: one x-certified with flags=encrypt, and another one
77+
# *not x-certified* with flags=sign. Subkey should become cross-certified
78+
# signing subkey.
79+
await make_key_from_parts [keyAndIdsPackets, subkeyPacket, encryptXSignPacket, signSigNoXSignPacket], esc defer km, w
80+
# Right now, KBPGP will throw that subkey completely. This happens because
81+
# the second binding "wins" (because it provides indefinite key lifetime),
82+
# but then in _check_subkeys it is found out that the binding provides no
83+
# cross cerfitication, so subkey is deemed invalid.
84+
T.assert w.warnings().length is 1, "expecting a warning"
85+
T.assert w.warnings()[0]?.indexOf("Subkey 0 was invalid") isnt -1, "found the right warning"
86+
now = testing_unixtime
87+
await do_message { armored : armoredMessage, keyfetch : km, now }, defer err, msg
88+
T.assert err?, "expecting an error"
89+
T.assert not(msg?), "do not return message"
7390
cb null
74-
# FIXME
75-
# esc = make_esc cb, "do_not_merge_crosscertify"
76-
# # Pass two bindings: one x-certified with flags=encrypt, and another one
77-
# # *not x-certified* with flags=sign. Subkey should become cross-certified
78-
# # signing subkey.
79-
# await make_key_from_parts [keyAndIdsPackets, subkeyPacket, encryptXSignPacket, signSigNoXSignPacket], esc defer km, w
80-
# # Right now, KBPGP will throw that subkey completely. This happens because
81-
# # the second binding "wins" (because it provides indefinite key lifetime),
82-
# # but then in _check_subkeys it is found out that the binding provides no
83-
# # cross cerfitication, so subkey is deemed invalid.
84-
# T.assert w.warnings().length is 1, "expecting a warning"
85-
# T.assert w.warnings()[0]?.indexOf("Subkey 0 was invalid") isnt -1, "found the right warning"
86-
# await do_message { armored : armoredMessage, keyfetch : km }, defer err, msg
87-
# T.assert err?, "expecting an error"
88-
# T.assert not(msg?), "do not return message"
89-
# cb null

0 commit comments

Comments
 (0)