Skip to content
Open
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
4 changes: 2 additions & 2 deletions src/librepgp/stream-sig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ signature_hash_key(const pgp_key_pkt_t &key, rnp::Hash &hash, pgp_version_t pgpv
break;
}
case PGP_V5: {
assert(key.pub_data.size() < ((size_t) 1 << 32));
assert(key.pub_data.size() < ((uint64_t) 1 << 32));
uint8_t hdr[5] = {0x9A, 0x00, 0x00, 0x00, 0x00};
write_uint32(hdr + 1, key.pub_data.size());
hash.add(&hdr, 5);
Expand All @@ -82,7 +82,7 @@ signature_hash_key(const pgp_key_pkt_t &key, rnp::Hash &hash, pgp_version_t pgpv
}
#if defined(ENABLE_CRYPTO_REFRESH)
case PGP_V6: {
assert(key.pub_data.size() < ((size_t) 1 << 32));
assert(key.pub_data.size() < ((uint64_t) 1 << 32));
uint8_t hdr[5] = {0x9b, 0x00, 0x00, 0x00, 0x00};
write_uint32(hdr + 1, key.pub_data.size());
hash.add(hdr, sizeof(hdr));
Expand Down
11 changes: 9 additions & 2 deletions src/tests/cli_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import time
import unittest
import random
import ctypes
from platform import architecture

from cli_common import (file_text, find_utility, is_windows, list_upto,
Expand Down Expand Up @@ -61,6 +62,13 @@ def escape_regex(str):
return '^' + ''.join((c, "[\\x{:02X}]".format(ord(c)))[0 <= ord(c) <= 0x20 \
or c in ['[',']','(',')','|','"','$','.','*','^','$','\\','+','?','{','}']] for c in str) + '$'

def time_t_is_greater_than_32bit() -> bool:
if hasattr(ctypes, 'c_time_t'):
return ctypes.sizeof(ctypes.c_time_t) > 4
else:
# probably Python < 3.12, just guess based on sys.maxsize
return sys.maxsize > 2 ** 32

UNICODE_LATIN_CAPITAL_A_GRAVE = unichr(192)
UNICODE_LATIN_SMALL_A_GRAVE = unichr(224)
UNICODE_LATIN_CAPITAL_A_MACRON = unichr(256)
Expand Down Expand Up @@ -3761,7 +3769,6 @@ def test_interactive_password(self):

def test_set_current_time(self):
# Too old date
is64bit = sys.maxsize > 2 ** 32
gparam = ['--homedir', RNPDIR2, '--notty', '--password', PASSWORD, '--generate-key', '--numbits', '1024', '--current-time']
rparam = ['--homedir', RNPDIR2, '--notty', '--remove-key']
ret, out, err = run_proc(RNPK, gparam + ['1950-01-02', '--userid', 'key-1950'])
Expand Down Expand Up @@ -3839,7 +3846,7 @@ def test_set_current_time(self):

# Try too distant date for expiration
ret, out, err = run_proc(RNPK, gparam + ['2024-02-29', '--expiration', '3024-02-29', '--userid', 'key-2924'])
if is64bit:
if time_t_is_greater_than_32bit():
self.assertEqual(ret, 1)
self.assertRegex(err, r'(?s)^.*Expiration time exceeds 32-bit value.*$')
self.assertRegex(err, r'(?s)^.*Failed to set primary key expiration..*$')
Expand Down
Loading