diff options
author | Jack Lloyd <[email protected]> | 2018-08-22 15:54:04 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-08-22 15:54:04 -0400 |
commit | 56468f8a389350516de67005c8e780c4f7743aab (patch) | |
tree | f151e3421fe9532087c9b62468e1a02344086478 /src | |
parent | 2fc2598ebab23aa63f7be30c8a2eff6afb262fb3 (diff) |
Simplify exception messages
Remove "Invalid argument" and "Decoding Error" prefixes
Diffstat (limited to 'src')
26 files changed, 89 insertions, 72 deletions
diff --git a/src/lib/pubkey/pkcs8.cpp b/src/lib/pubkey/pkcs8.cpp index 8d3eba6dc..c91e436c7 100644 --- a/src/lib/pubkey/pkcs8.cpp +++ b/src/lib/pubkey/pkcs8.cpp @@ -97,7 +97,7 @@ secure_vector<uint8_t> PKCS8_decode( } catch(Decoding_Error& e) { - throw Decoding_Error("PKCS #8 private key decoding failed: " + std::string(e.what())); + throw Decoding_Error("PKCS #8 private key decoding", e); } try @@ -126,7 +126,7 @@ secure_vector<uint8_t> PKCS8_decode( } catch(std::exception& e) { - throw Decoding_Error("PKCS #8 private key decoding failed: " + std::string(e.what())); + throw Decoding_Error("PKCS #8 private key decoding", e); } return key; } diff --git a/src/lib/pubkey/x509_key.cpp b/src/lib/pubkey/x509_key.cpp index 6e49d953a..fff75ec44 100644 --- a/src/lib/pubkey/x509_key.cpp +++ b/src/lib/pubkey/x509_key.cpp @@ -62,13 +62,13 @@ Public_Key* load_key(DataSource& source) } if(key_bits.empty()) - throw Decoding_Error("X.509 public key decoding failed"); + throw Decoding_Error("X.509 public key decoding"); return load_public_key(alg_id, key_bits).release(); } catch(Decoding_Error& e) { - throw Decoding_Error("X.509 public key decoding failed: " + std::string(e.what())); + throw Decoding_Error("X.509 public key decoding", e); } } diff --git a/src/lib/utils/exceptn.cpp b/src/lib/utils/exceptn.cpp index a72e45ba4..cc6eb9f85 100644 --- a/src/lib/utils/exceptn.cpp +++ b/src/lib/utils/exceptn.cpp @@ -11,18 +11,25 @@ namespace Botan { Exception::Exception(const std::string& msg) : m_msg(msg) {} +Exception::Exception(const std::string& msg, const std::exception& e) : + m_msg(msg + " failed with " + std::string(e.what())) + {} + Exception::Exception(const char* prefix, const std::string& msg) : m_msg(std::string(prefix) + " " + msg) {} Invalid_Argument::Invalid_Argument(const std::string& msg) : - Exception("Invalid argument", msg) + Exception(msg) {} Invalid_Argument::Invalid_Argument(const std::string& msg, const std::string& where) : - Exception("Invalid argument", msg + " in " + where) + Exception(msg + " in " + where) {} +Invalid_Argument::Invalid_Argument(const std::string& msg, const std::exception& e) : + Exception(msg, e) {} + Lookup_Error::Lookup_Error(const std::string& type, const std::string& algo, const std::string& provider) : @@ -76,11 +83,15 @@ Encoding_Error::Encoding_Error(const std::string& name) : {} Decoding_Error::Decoding_Error(const std::string& name) : - Invalid_Argument("Decoding error: " + name) + Invalid_Argument(name) + {} + +Decoding_Error::Decoding_Error(const std::string& msg, const std::exception& e) : + Invalid_Argument(msg, e) {} Decoding_Error::Decoding_Error(const std::string& name, const char* exception_message) : - Invalid_Argument("Decoding error: " + name + " failed with exception " + exception_message) {} + Invalid_Argument(name + " failed with exception " + exception_message) {} Integrity_Failure::Integrity_Failure(const std::string& msg) : Exception("Integrity failure: " + msg) diff --git a/src/lib/utils/exceptn.h b/src/lib/utils/exceptn.h index f2896aa83..efa52580c 100644 --- a/src/lib/utils/exceptn.h +++ b/src/lib/utils/exceptn.h @@ -23,6 +23,8 @@ class BOTAN_PUBLIC_API(2,0) Exception : public std::exception Exception(const char* prefix, const std::string& msg); explicit Exception(const std::string& msg); const char* what() const BOTAN_NOEXCEPT override { return m_msg.c_str(); } + protected: + Exception(const std::string& msg, const std::exception& e); private: std::string m_msg; }; @@ -36,7 +38,9 @@ class BOTAN_PUBLIC_API(2,0) Invalid_Argument : public Exception explicit Invalid_Argument(const std::string& msg); explicit Invalid_Argument(const std::string& msg, const std::string& where); -}; + + Invalid_Argument(const std::string& msg, const std::exception& e); + }; /** * Unsupported_Argument Exception @@ -178,6 +182,8 @@ class BOTAN_PUBLIC_API(2,0) Decoding_Error : public Invalid_Argument explicit Decoding_Error(const std::string& name); Decoding_Error(const std::string& name, const char* exception_message); + + Decoding_Error(const std::string& msg, const std::exception& e); }; /** diff --git a/src/lib/x509/x509_ext.cpp b/src/lib/x509/x509_ext.cpp index 122be2885..5a5ffa177 100644 --- a/src/lib/x509/x509_ext.cpp +++ b/src/lib/x509/x509_ext.cpp @@ -101,7 +101,7 @@ Extensions::create_extn_obj(const OID& oid, } catch(Decoding_Error& e) { - throw Decoding_Error("Decoding X.509 extension " + oid.as_string() + " failed", e.what()); + throw Decoding_Error("Decoding X.509 extension " + oid.as_string(), e); } return extn; } diff --git a/src/lib/x509/x509_obj.cpp b/src/lib/x509/x509_obj.cpp index 060453072..49d7fcc60 100644 --- a/src/lib/x509/x509_obj.cpp +++ b/src/lib/x509/x509_obj.cpp @@ -85,7 +85,7 @@ void X509_Object::load_data(DataSource& in) } catch(Decoding_Error& e) { - throw Decoding_Error(PEM_label() + " decoding failed: " + e.what()); + throw Decoding_Error(PEM_label() + " decoding", e); } } diff --git a/src/lib/x509/x509cert.cpp b/src/lib/x509/x509cert.cpp index ddfe5d5b2..9ed521f16 100644 --- a/src/lib/x509/x509cert.cpp +++ b/src/lib/x509/x509cert.cpp @@ -650,7 +650,7 @@ std::unique_ptr<Public_Key> X509_Certificate::load_subject_public_key() const } catch(std::exception& e) { - throw Decoding_Error("X509_Certificate::load_subject_public_key", e.what()); + throw Decoding_Error("X509_Certificate::load_subject_public_key", e); } } diff --git a/src/tests/data/tls/alert.vec b/src/tests/data/tls/alert.vec index 19ec8839b..cd5058212 100644 --- a/src/tests/data/tls/alert.vec +++ b/src/tests/data/tls/alert.vec @@ -14,11 +14,11 @@ Exception = Buffer = 0030 Protocol = 0303 -Exception = Invalid argument Decoding error: Alert: Bad code for alert level +Exception = Alert: Bad code for alert level Buffer = 02 -Exception = Invalid argument Decoding error: Alert: Bad size 1 for alert message +Exception = Alert: Bad size 1 for alert message Buffer = 020101 -Exception = Invalid argument Decoding error: Alert: Bad size 3 for alert message +Exception = Alert: Bad size 3 for alert message diff --git a/src/tests/data/tls/cert_status.vec b/src/tests/data/tls/cert_status.vec index d93f800ab..c01c10951 100644 --- a/src/tests/data/tls/cert_status.vec +++ b/src/tests/data/tls/cert_status.vec @@ -1,16 +1,16 @@ [cert_status] Buffer = 00 -Exception = Invalid argument Decoding error: Invalid Certificate_Status message: too small +Exception = Invalid Certificate_Status message: too small Buffer = 01 -Exception = Invalid argument Decoding error: Invalid Certificate_Status message: too small +Exception = Invalid Certificate_Status message: too small Buffer = 01000000 -Exception = Invalid argument Decoding error: Invalid Certificate_Status message: too small +Exception = Invalid Certificate_Status message: too small Buffer = 010FFFF000 -Exception = Invalid argument Decoding error: Invalid Certificate_Status: invalid length field +Exception = Invalid Certificate_Status: invalid length field Buffer = 0100020F3082020B0A0100A08202043082020006092B0601050507300101048201F1308201ED3081D6A14C304A310B300906035504061302555331163014060355040A130D4C6574277320456E6372797074312330210603550403131A4C6574277320456E637279707420417574686F72697479205833180F32303136313131383132313630305A30753073304B300906052B0E03021A050004147EE66AE7729AB3FCF8A220646C16A12D6071085D0414A84A6A63047DDDBAE6D139B7A64565EFF3A8ECA1021203E89ED07A424B72A35FAD167F48A4F25AD28000180F32303136313131383132303030305AA011180F32303136313132353132303030305A300D06092A864886F70D01010B050003820101007CB8774D813E6E0FBFA816BE53F5F3131EF9DED7B0928BBE50AC628C90C811DBBFE0E43A98BF3FB608CC230EFE31FE98BE99016D98DE73028F6C1AE8C34B0F20DD7E688604322538E721EF9D0D353EADE8818BFB63DA8078A7E2BF9E637282DE6C79B2289F0C13807A9D3B7532970FF0AA77CE06A06299B02274ED6C62DFC672485405C1859FEBDFC3B5B2D81A0A45382FFABBF75D6EAC1AD1AF12701DCDF87F0EFEB41933AED08EF78B35F48362A792E55027F00B3EE4571F30212A3EB7BE4B934F67685A4AF2BBF428280BC20D1A42E75DBE42C459541B4E1EE5BB99E0CCA166C2E9C2E6054F147F2FDF33F104E9076061640EDDB12B62BEAA82E0D60ED128 Name = Let's Encrypt Authority X3 diff --git a/src/tests/data/tls/cert_verify.vec b/src/tests/data/tls/cert_verify.vec index d36156cc2..335cb8353 100644 --- a/src/tests/data/tls/cert_verify.vec +++ b/src/tests/data/tls/cert_verify.vec @@ -24,17 +24,17 @@ Exception = #Incomplete algorithm Buffer = 06 Protocol = 0303 -Exception = Invalid argument Decoding error: Invalid CertificateVerify: Expected 2 bytes remaining, only 1 left +Exception = Invalid CertificateVerify: Expected 2 bytes remaining, only 1 left #Incomplete certificate Buffer = 0601000500 Protocol = 0303 -Exception = Invalid argument Decoding error: Invalid CertificateVerify: Expected 5 bytes remaining, only 1 left +Exception = Invalid CertificateVerify: Expected 5 bytes remaining, only 1 left Buffer = 000200 Protocol = 0302 -Exception = Invalid argument Decoding error: Invalid CertificateVerify: Expected 2 bytes remaining, only 1 left +Exception = Invalid CertificateVerify: Expected 2 bytes remaining, only 1 left Buffer = 000200 Protocol = 0301 -Exception = Invalid argument Decoding error: Invalid CertificateVerify: Expected 2 bytes remaining, only 1 left +Exception = Invalid CertificateVerify: Expected 2 bytes remaining, only 1 left diff --git a/src/tests/data/tls/client_hello.vec b/src/tests/data/tls/client_hello.vec index afd8e83c1..40d883ede 100644 --- a/src/tests/data/tls/client_hello.vec +++ b/src/tests/data/tls/client_hello.vec @@ -25,44 +25,44 @@ Exception = # empty Buffer = Protocol = 0303 -Exception = Invalid argument Decoding error: Client_Hello: Packet corrupted +Exception = Client_Hello: Packet corrupted Buffer = 00 Protocol = 0303 -Exception = Invalid argument Decoding error: Client_Hello: Packet corrupted +Exception = Client_Hello: Packet corrupted # Invalid cipher suite length (0xf0e2 instead of 0x00e2) Buffer = 0303e00da23523058b5dc9c445d97b2bb6315b019e97838ac4f16c23b2cb031b6a4900f0e2c0afc0adc030c02cc028c024c014c00ac0a3c09f00a500a300a1009f006b006a006900680039003800370036cca9cca8c077c073ccaa00c400c300c200c10088008700860085c032c02ec02ac026c00fc005c079c075c0a1c09d009d003d003500c00084c0aec0acc02fc02bc027c023c013c009c0a2c09e00a400a200a0009e00670040003f003e0033003200310030c076c07200be00bd00bc00bb009a0099009800970045004400430042c031c02dc029c025c00ec004c078c074c0a0c09c009c003c002f00ba009600410007c012c008001600130010000dc00dc003000a00ff01000000 Protocol = 0303 AdditionalData = -Exception = Invalid argument Decoding error: Invalid ClientHello: Expected 61666 bytes remaining, only 230 left +Exception = Invalid ClientHello: Expected 61666 bytes remaining, only 230 left #invalid extensions length Buffer = 030320f3dc33f90be6509e6133a1819f2b80fe6ccc6268d9195ca4ead7504ffe7e2a0000aac030c02cc028c024c014c00a00a500a300a1009f006b006a0069006800390038003700360088008700860085c032c02ec02ac026c00fc005009d003d00350084c02fc02bc027c023c013c00900a400a200a0009e00670040003f003e0033003200310030009a0099009800970045004400430042c031c02dc029c025c00ec004009c003c002f00960041c011c007c00cc00200050004c012c008001600130010000dc00dc003000a00ff01000001 Protocol = 0303 -Exception = Invalid argument Decoding error: Bad extension size +Exception = Bad extension size #invalid extensions length 2 Buffer = 030320f3dc33f90be6509e6133a1819f2b80fe6ccc6268d9195ca4ead7504ffe7e2a0000aac030c02cc028c024c014c00a00a500a300a1009f006b006a0069006800390038003700360088008700860085c032c02ec02ac026c00fc005009d003d00350084c02fc02bc027c023c013c00900a400a200a0009e00670040003f003e0033003200310030009a0099009800970045004400430042c031c02dc029c025c00ec004009c003c002f00960041c011c007c00cc00200050004c012c008001600130010000dc00dc003000a00ff010000010000 Protocol = 0303 -Exception = Invalid argument Decoding error: Bad extension size +Exception = Bad extension size #invalid length of the supported groups extension (0xf01c instead of 0x001c) Buffer = 0303871e18983024eaee1be8ae6607d5ecad941d33fd7fc1d8554a9e1fbfda8d30880000aac030c02cc028c024c014c00a00a500a300a1009f006b006a0069006800390038003700360088008700860085c032c02ec02ac026c00fc005009d003d00350084c02fc02bc027c023c013c00900a400a200a0009e00670040003f003e0033003200310030009a0099009800970045004400430042c031c02dc029c025c00ec004009c003c002f00960041c011c007c00cc00200050004c012c008001600130010000dc00dc003000a00ff01000055000b000403000102000af01c001a00170019001c001b0018001a0016000e000d000b000c0009000a00230000000d0020001e060106020603050105020503040104020403030103020303020102020203000f000101 Protocol = 0303 -Exception = Invalid argument Decoding error: Inconsistent length field in supported groups list +Exception = Inconsistent length field in supported groups list #invalid length of the supported groups extension (0xf01a instead of 0x001a) Buffer = 0303871e18983024eaee1be8ae6607d5ecad941d33fd7fc1d8554a9e1fbfda8d30880000aac030c02cc028c024c014c00a00a500a300a1009f006b006a0069006800390038003700360088008700860085c032c02ec02ac026c00fc005009d003d00350084c02fc02bc027c023c013c00900a400a200a0009e00670040003f003e0033003200310030009a0099009800970045004400430042c031c02dc029c025c00ec004009c003c002f00960041c011c007c00cc00200050004c012c008001600130010000dc00dc003000a00ff01000055000b000403000102000a001cf01a00170019001c001b0018001a0016000e000d000b000c0009000a00230000000d0020001e060106020603050105020503040104020403030103020303020102020203000f000101 Protocol = 0303 -Exception = Invalid argument Decoding error: Inconsistent length field in supported groups list +Exception = Inconsistent length field in supported groups list #invalid length of the session ticket extension Buffer = 0303871e18983024eaee1be8ae6607d5ecad941d33fd7fc1d8554a9e1fbfda8d30880000aac030c02cc028c024c014c00a00a500a300a1009f006b006a0069006800390038003700360088008700860085c032c02ec02ac026c00fc005009d003d00350084c02fc02bc027c023c013c00900a400a200a0009e00670040003f003e0033003200310030009a0099009800970045004400430042c031c02dc029c025c00ec004009c003c002f00960041c011c007c00cc00200050004c012c008001600130010000dc00dc003000a00ff01000055000b000403000102000a001c001a00170019001c001b0018001a0016000e000d000b000c0009000a002300ff000d0020001e060106020603050105020503040104020403030103020303020102020203000f000101 Protocol = 0303 -Exception = Invalid argument Decoding error: Invalid ClientHello: Expected 255 bytes remaining, only 41 left +Exception = Invalid ClientHello: Expected 255 bytes remaining, only 41 left #invalid length of the heartbeat extension Buffer = 0303871e18983024eaee1be8ae6607d5ecad941d33fd7fc1d8554a9e1fbfda8d30880000aac030c02cc028c024c014c00a00a500a300a1009f006b006a0069006800390038003700360088008700860085c032c02ec02ac026c00fc005009d003d00350084c02fc02bc027c023c013c00900a400a200a0009e00670040003f003e0033003200310030009a0099009800970045004400430042c031c02dc029c025c00ec004009c003c002f00960041c011c007c00cc00200050004c012c008001600130010000dc00dc003000a00ff01000055000b000403000102000a001c001a00170019001c001b0018001a0016000e000d000b000c0009000a00230000000d0020001e060106020603050105020503040104020403030103020303020102020203000f000201 Protocol = 0303 -Exception = Invalid argument Decoding error: Invalid ClientHello: Expected 2 bytes remaining, only 1 left +Exception = Invalid ClientHello: Expected 2 bytes remaining, only 1 left diff --git a/src/tests/data/tls/hello_request.vec b/src/tests/data/tls/hello_request.vec index 3a7471ae4..280acada9 100644 --- a/src/tests/data/tls/hello_request.vec +++ b/src/tests/data/tls/hello_request.vec @@ -5,4 +5,4 @@ Buffer = Exception = Buffer = 01 -Exception = Invalid argument Decoding error: Bad Hello_Request, has non-zero size +Exception = Bad Hello_Request, has non-zero size diff --git a/src/tests/data/tls/hello_verify.vec b/src/tests/data/tls/hello_verify.vec index f5db9e085..59fc1c337 100644 --- a/src/tests/data/tls/hello_verify.vec +++ b/src/tests/data/tls/hello_verify.vec @@ -10,17 +10,17 @@ Exception = # HelloVerify request has to contain at least 3 bytes Buffer = 0101 -Exception = Invalid argument Decoding error: Hello verify request too small +Exception = Hello verify request too small # HelloVerify has to contain valid protocol version Buffer = 010100 -Exception = Invalid argument Decoding error: Unknown version from server in hello verify request +Exception = Unknown version from server in hello verify request # HelloVerify has to contain valid number of bytes Buffer = FEFD0000 -Exception = Invalid argument Decoding error: Bad length in hello verify request +Exception = Bad length in hello verify request # HelloVerify has to contain valid number of bytes Buffer = FEFD0500 -Exception = Invalid argument Decoding error: Bad length in hello verify request +Exception = Bad length in hello verify request diff --git a/src/tests/data/tls/new_session_ticket.vec b/src/tests/data/tls/new_session_ticket.vec index 22c03611e..bfc069149 100644 --- a/src/tests/data/tls/new_session_ticket.vec +++ b/src/tests/data/tls/new_session_ticket.vec @@ -14,7 +14,7 @@ Buffer = 0000000000051122334455 Exception = Buffer = 0001 -Exception = Invalid argument Decoding error: Session ticket message too short to be valid +Exception = Session ticket message too short to be valid Buffer = 00010203000500 -Exception = Invalid argument Decoding error: Invalid SessionTicket: Expected 5 bytes remaining, only 1 left
\ No newline at end of file +Exception = Invalid SessionTicket: Expected 5 bytes remaining, only 1 left
\ No newline at end of file diff --git a/src/tests/data/tls/server_hello.vec b/src/tests/data/tls/server_hello.vec index c4daed84e..481ad02b8 100644 --- a/src/tests/data/tls/server_hello.vec +++ b/src/tests/data/tls/server_hello.vec @@ -24,25 +24,25 @@ Buffer = Protocol = 0303 Ciphersuite = C030 AdditionalData = -Exception = Invalid argument Decoding error: Server_Hello: Packet corrupted +Exception = Server_Hello: Packet corrupted # incorrect, corrupted Buffer = 00 Protocol = 0303 Ciphersuite = C030 AdditionalData = -Exception = Invalid argument Decoding error: Server_Hello: Packet corrupted +Exception = Server_Hello: Packet corrupted # invalid extensions length Buffer = 03039f9cafa88664d9095f85dd64a39e5dd5c09f5a4a5362938af3718ee4e818af6a00c03000001cff01000100000b00040300010200230000000f00010100170000 Protocol = 0303 Ciphersuite = C030 AdditionalData = 00170023FF01 -Exception = Invalid argument Decoding error: Bad extension size +Exception = Bad extension size # invalid extension length Buffer = 03039f9cafa88664d9095f85dd64a39e5dd5c09f5a4a5362938af3718ee4e818af6a00c03000001aff01000100000b00040300010200230100000f00010100170000 Protocol = 0303 Ciphersuite = C030 AdditionalData = 00170023FF01 -Exception = Invalid argument Decoding error: Invalid ServerHello: Expected 256 bytes remaining, only 9 left +Exception = Invalid ServerHello: Expected 256 bytes remaining, only 9 left diff --git a/src/tests/data/x509/bsi/expected.txt b/src/tests/data/x509/bsi/expected.txt index e47f978b1..8037c6aca 100644 --- a/src/tests/data/x509/bsi/expected.txt +++ b/src/tests/data/x509/bsi/expected.txt @@ -3,15 +3,15 @@ cert_path_algo_strength_02$Hash function used is considered too weak for securit cert_path_algo_strength_03$Signature error cert_path_common_01$Verified cert_path_common_02$Cannot establish trust -cert_path_common_03$Invalid argument Decoding error: CERTIFICATE decoding failed: Invalid argument Decoding error: X.509 Certificate had differing algorithm identifers in inner and outer ID fields +cert_path_common_03$CERTIFICATE decoding failed with X.509 Certificate had differing algorithm identifers in inner and outer ID fields cert_path_common_04$Certificate signed with unknown/unavailable algorithm -cert_path_common_05$Invalid argument Decoding error: CERTIFICATE decoding failed: Invalid argument Decoding error: BER: Value truncated +cert_path_common_05$CERTIFICATE decoding failed with BER: Value truncated cert_path_common_06$Warning: Certificate serial number is negative cert_path_common_07$Certificate is not yet valid cert_path_common_08$Certificate has expired cert_path_common_09$Certificate is not yet valid cert_path_common_10$Certificate has expired -cert_path_common_11$Invalid argument Decoding error: CERTIFICATE decoding failed: Invalid argument Decoding error: Unknown X.509 cert version 5 +cert_path_common_11$CERTIFICATE decoding failed with Unknown X.509 cert version 5 cert_path_common_12$Warning: Distinguished name too long cert_path_common_13$Verified cert_path_common_14$Verified @@ -28,7 +28,7 @@ cert_path_CRL_10$Certificate is revoked cert_path_CRL_11$Certificate is revoked cert_path_CRL_12$No revocation data cert_path_CRL_13$No CRL with matching distribution point for certificate -cert_path_CRL_14$Invalid argument Decoding error: X509 CRL decoding failed: Invalid argument Decoding error: BER: Tag mismatch when decoding object got EOF expected BIT STRING/UNIVERSAL +cert_path_CRL_14$X509 CRL decoding failed with BER: Tag mismatch when decoding object got EOF expected BIT STRING/UNIVERSAL cert_path_CRL_15$No CRL with matching distribution point for certificate cert_path_CRL_16$Certificate is revoked cert_path_crypt_01$Signature error @@ -42,7 +42,7 @@ cert_path_ext_06$CA certificate not allowed to issue certs cert_path_ext_07$CA certificate not allowed to issue certs cert_path_ext_08$Certificate chain too long cert_path_ext_09$Verified -cert_path_ext_10$Invalid argument Decoding error: CERTIFICATE decoding failed: Invalid argument Decoding error: Decoding X.509 extension 2.5.29.15 failed failed with exception Invalid argument Decoding error: BER: Tag mismatch when decoding usage constraint got SEQUENCE/CONSTRUCTED expected BIT STRING/UNIVERSAL +cert_path_ext_10$CERTIFICATE decoding failed with Decoding X.509 extension 2.5.29.15 failed with BER: Tag mismatch when decoding usage constraint got SEQUENCE/CONSTRUCTED expected BIT STRING/UNIVERSAL cert_path_ext_11$CA certificate not allowed to issue certs cert_path_ext_12$Certificate contains duplicate policy cert_path_ext_13$Unknown critical extension encountered diff --git a/src/tests/test_bigint.cpp b/src/tests/test_bigint.cpp index 146a9e8c9..ad0af03f4 100644 --- a/src/tests/test_bigint.cpp +++ b/src/tests/test_bigint.cpp @@ -91,13 +91,13 @@ class BigInt_Unit_Tests final : public Test Test::Result result("BigInt prime generation"); result.test_throws("Invalid bit size", - "Invalid argument random_prime: Can't make a prime of 0 bits", + "random_prime: Can't make a prime of 0 bits", []() { Botan::random_prime(Test::rng(), 0); }); result.test_throws("Invalid bit size", - "Invalid argument random_prime: Can't make a prime of 1 bits", + "random_prime: Can't make a prime of 1 bits", []() { Botan::random_prime(Test::rng(), 1); }); result.test_throws("Invalid arg", - "Invalid argument random_prime Invalid value for equiv/modulo", + "random_prime Invalid value for equiv/modulo", []() { Botan::random_prime(Test::rng(), 2, 1, 0, 2); }); BigInt p = Botan::random_prime(Test::rng(), 2); diff --git a/src/tests/test_dh.cpp b/src/tests/test_dh.cpp index 77778925f..49da13d12 100644 --- a/src/tests/test_dh.cpp +++ b/src/tests/test_dh.cpp @@ -89,7 +89,7 @@ class Diffie_Hellman_KAT_Tests final : public PK_Key_Agreement_Test std::unique_ptr<Botan::PK_Key_Agreement> kas(new Botan::PK_Key_Agreement(*privkey, rng(), "Raw")); result.test_throws("agreement input too big", - "Invalid argument DH agreement - invalid key provided", + "DH agreement - invalid key provided", [&kas]() { const BigInt too_big("584580020955360946586837552585233629614212007514394561597561641914945762794672"); @@ -97,7 +97,7 @@ class Diffie_Hellman_KAT_Tests final : public PK_Key_Agreement_Test }); result.test_throws("agreement input too small", - "Invalid argument DH agreement - invalid key provided", + "DH agreement - invalid key provided", [&kas]() { const BigInt too_small("1"); diff --git a/src/tests/test_dl_group.cpp b/src/tests/test_dl_group.cpp index 64a59f22c..159454b3f 100644 --- a/src/tests/test_dl_group.cpp +++ b/src/tests/test_dl_group.cpp @@ -47,7 +47,7 @@ class DL_Group_Tests final : public Test if(Test::options().undefined_behavior_allowed()) { result.test_throws("Bad generator param", - "Invalid argument DL_Group unknown PrimeType", + "DL_Group unknown PrimeType", []() { auto invalid_type = static_cast<Botan::DL_Group::PrimeType>(9); Botan::DL_Group dl(Test::rng(), invalid_type, 1024); @@ -129,11 +129,11 @@ class DL_Group_Tests final : public Test const std::vector<uint8_t> working_seed = Botan::hex_decode("0000000000000000000000000000000000000021"); result.test_throws("DSA seed does not generate group", - "Invalid argument DL_Group: The seed given does not generate a DSA group", + "DL_Group: The seed given does not generate a DSA group", [&rng,&invalid_seed]() { Botan::DL_Group dsa(rng, invalid_seed, 1024, 160); }); result.test_throws("DSA seed is too short", - "Invalid argument Generating a DSA parameter set with a 160 bit long q requires a seed at least as many bits long", + "Generating a DSA parameter set with a 160 bit long q requires a seed at least as many bits long", [&rng,&short_seed]() { Botan::DL_Group dsa(rng, short_seed, 1024, 160); }); // From FIPS 186-3 test data diff --git a/src/tests/test_filters.cpp b/src/tests/test_filters.cpp index cc40cccbe..33649e56a 100644 --- a/src/tests/test_filters.cpp +++ b/src/tests/test_filters.cpp @@ -216,11 +216,11 @@ class Filter_Tests final : public Test // can't explicitly insert a queue into the pipe because they are implicit result.test_throws("pipe error", - "Invalid argument Pipe::append: SecureQueue cannot be used", + "Pipe::append: SecureQueue cannot be used", [&]() { pipe.append(queue_filter.get()); }); result.test_throws("pipe error", - "Invalid argument Pipe::prepend: SecureQueue cannot be used", + "Pipe::prepend: SecureQueue cannot be used", [&]() { pipe.prepend(queue_filter.get()); }); pipe.append_filter(new Botan::BitBucket); // succeeds @@ -266,7 +266,7 @@ class Filter_Tests final : public Test [&]() { pipe.prepend_filter(filter.get()); }); result.test_throws("pipe error", - "Invalid argument Pipe::read: Invalid message number 100", + "Pipe::read: Invalid message number 100", [&]() { uint8_t b; size_t got = pipe.read(&b, 1, 100); BOTAN_UNUSED(got); }); pipe.append(nullptr); // ignored @@ -288,7 +288,7 @@ class Filter_Tests final : public Test mac_filter->set_iv(Botan::InitializationVector()); // ignored result.test_throws("Keyed_Filter::set_iv throws if not implemented", - "Invalid argument IV length 1 is invalid for HMAC(SHA-256)", + "IV length 1 is invalid for HMAC(SHA-256)", [mac_filter]() { mac_filter->set_iv(Botan::InitializationVector("AA")); }); Botan::Pipe pipe(mac_filter, diff --git a/src/tests/test_hash.cpp b/src/tests/test_hash.cpp index 6b69b5be4..228240b58 100644 --- a/src/tests/test_hash.cpp +++ b/src/tests/test_hash.cpp @@ -47,7 +47,7 @@ class Invalid_Hash_Name_Tests final : public Test catch(Botan::Invalid_Argument& e) { const std::string msg = e.what(); - const std::string full_msg = "Invalid argument " + expected_msg; + const std::string full_msg = "" + expected_msg; result.test_eq("expected error message", msg, full_msg); } catch(Botan::Lookup_Error& e) diff --git a/src/tests/test_passhash.cpp b/src/tests/test_passhash.cpp index 546dce39e..b6bd268b1 100644 --- a/src/tests/test_passhash.cpp +++ b/src/tests/test_passhash.cpp @@ -63,7 +63,7 @@ class Bcrypt_Tests final : public Text_Based_Test } result.test_throws("Invalid bcrypt version rejected", - "Invalid argument Unknown bcrypt version 'q'", + "Unknown bcrypt version 'q'", []() { Botan::generate_bcrypt("pass", Test::rng(), 4, 'q'); }); result.set_ns_consumed(Test::timestamp() - start); @@ -138,11 +138,11 @@ class Passhash9_Tests final : public Text_Based_Test Botan::is_passhash9_alg_supported(255) == false); result.test_throws("Throws if algorithm not supported", - "Invalid argument Passhash9: Algorithm id 255 is not defined", + "Passhash9: Algorithm id 255 is not defined", []() { Botan::generate_passhash9("pass", Test::rng(), 3, 255); }); result.test_throws("Throws if iterations is too high", - "Invalid argument Requested passhash9 work factor 513 is too large", + "Requested passhash9 work factor 513 is too large", []() { Botan::check_passhash9("floof", "$9$AgIB3c5J3kvAuML84sZ5hWT9WzJtiYRPLCEARaujS7I6IKbNCwp0"); }); return {result}; } diff --git a/src/tests/test_pem.cpp b/src/tests/test_pem.cpp index bf5913ced..5fc8080dd 100644 --- a/src/tests/test_pem.cpp +++ b/src/tests/test_pem.cpp @@ -33,17 +33,17 @@ class PEM_Tests : public Test result.test_eq("PEM decoding label", label1, "BUNNY"); result.test_throws("PEM decoding unexpected label", - "Invalid argument Decoding error: PEM: Label mismatch, wanted FLOOFY, got BUNNY", + "PEM: Label mismatch, wanted FLOOFY, got BUNNY", [pem1]() { Botan::PEM_Code::decode_check_label(pem1, "FLOOFY"); }); const std::string malformed_pem1 = "---BEGIN BUNNY-----\n-----END BUNNY-----"; result.test_throws("PEM decoding bad init label", - "Invalid argument Decoding error: PEM: No PEM header found", + "PEM: No PEM header found", [malformed_pem1]() { Botan::PEM_Code::decode_check_label(malformed_pem1, "BUNNY"); }); const std::string malformed_pem2 = "-----BEGIN BUNNY-----\n-----END FLOOFY-----"; result.test_throws("PEM decoding bad init label", - "Invalid argument Decoding error: PEM: Malformed PEM trailer", + "PEM: Malformed PEM trailer", [malformed_pem2]() { Botan::PEM_Code::decode_check_label(malformed_pem2, "BUNNY"); }); diff --git a/src/tests/test_psk_db.cpp b/src/tests/test_psk_db.cpp index 87a0b4381..4271d400a 100644 --- a/src/tests/test_psk_db.cpp +++ b/src/tests/test_psk_db.cpp @@ -148,7 +148,7 @@ class PSK_DB_Tests final : public Test result.test_eq("Have expected name", all_names.count("leroy jeeeeeeeenkins"), 1); result.test_throws("exception if get called on non-existent PSK", - "Invalid argument Named PSK not located", + "Named PSK not located", [&]() { db.get("name2"); }); // test that redundant remove calls accepted @@ -238,7 +238,7 @@ class PSK_DB_Tests final : public Test result.test_eq("Have expected name", all_names.count("leroy jeeeeeeeenkins"), 1); result.test_throws("exception if get called on non-existent PSK", - "Invalid argument Named PSK not located", + "Named PSK not located", [&]() { db.get("name2"); }); // test that redundant remove calls accepted diff --git a/src/tests/unit_ecdsa.cpp b/src/tests/unit_ecdsa.cpp index 260eb8571..88c3a4d05 100644 --- a/src/tests/unit_ecdsa.cpp +++ b/src/tests/unit_ecdsa.cpp @@ -304,7 +304,7 @@ Test::Result test_encoding_options() auto invalid_format = static_cast<Botan::PointGFp::Compression_Type>(99); result.test_throws("Invalid point format throws", - "Invalid argument Invalid point encoding for EC_PublicKey", + "Invalid point encoding for EC_PublicKey", [&] { key.set_point_encoding(invalid_format); }); } diff --git a/src/tests/unit_x509.cpp b/src/tests/unit_x509.cpp index 265f426af..b0a5da23a 100644 --- a/src/tests/unit_x509.cpp +++ b/src/tests/unit_x509.cpp @@ -565,7 +565,7 @@ Test::Result test_x509_authority_info_access_extension() { test_result.test_eq("Build CA certitiface with invalid encoding scheme EMSA1 for key type " + sk->algo_name(), e.what(), - "Invalid argument Encoding scheme with canonical name EMSA1 not supported for signature algorithm RSA"); + "Encoding scheme with canonical name EMSA1 not supported for signature algorithm RSA"); } #endif @@ -591,7 +591,7 @@ Test::Result test_x509_authority_info_access_extension() { test_result.test_eq("Configured conflicting hash functions for CA", e.what(), - "Invalid argument Hash function from opts and hash_fn argument need to be identical"); + "Hash function from opts and hash_fn argument need to be identical"); } // Create X509 CA object: its signer will use the padding scheme from the CA certificate, i.e. EMSA3 |