diff options
author | Jack Lloyd <[email protected]> | 2017-09-07 10:30:11 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-09-07 10:30:11 -0400 |
commit | f3d2b1b68592ce11da07129e8f6afa69a094bf14 (patch) | |
tree | f91a0a6f545fe29a5cac20ade8b34682f9a19ed6 | |
parent | 1a39eca36d5b2f41b3178fbb1a359e42d47b7a74 (diff) | |
parent | 8a9722d234eef597353afa3c819335d5aec64875 (diff) |
Merge GH #1189 Correct return value of botan_pk_op_verify_finish
-rw-r--r-- | src/lib/ffi/ffi.h | 2 | ||||
-rw-r--r-- | src/lib/ffi/ffi_kdf.cpp | 2 | ||||
-rw-r--r-- | src/lib/ffi/ffi_pk_op.cpp | 2 | ||||
-rw-r--r-- | src/tests/test_ffi.cpp | 18 |
4 files changed, 13 insertions, 11 deletions
diff --git a/src/lib/ffi/ffi.h b/src/lib/ffi/ffi.h index 005d32eee..de752f43c 100644 --- a/src/lib/ffi/ffi.h +++ b/src/lib/ffi/ffi.h @@ -136,6 +136,8 @@ doesn't exactly work well either! */ #define BOTAN_FFI_SUCCESS (0) +#define BOTAN_FFI_INVALID_VERIFIER (1) + #define BOTAN_FFI_ERROR_INVALID_INPUT (-1) #define BOTAN_FFI_ERROR_BAD_MAC (-2) diff --git a/src/lib/ffi/ffi_kdf.cpp b/src/lib/ffi/ffi_kdf.cpp index 1a4c40893..7aaf2dbe8 100644 --- a/src/lib/ffi/ffi_kdf.cpp +++ b/src/lib/ffi/ffi_kdf.cpp @@ -88,7 +88,7 @@ int botan_bcrypt_is_valid(const char* pass, const char* hash) { #if defined(BOTAN_HAS_BCRYPT) return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() { - return Botan::check_bcrypt(pass, hash) ? 0 : 1; + return Botan::check_bcrypt(pass, hash) ? BOTAN_FFI_SUCCESS : BOTAN_FFI_INVALID_VERIFIER; }); #else return BOTAN_FFI_ERROR_NOT_IMPLEMENTED; diff --git a/src/lib/ffi/ffi_pk_op.cpp b/src/lib/ffi/ffi_pk_op.cpp index d0ac8e3c7..fa3b32725 100644 --- a/src/lib/ffi/ffi_pk_op.cpp +++ b/src/lib/ffi/ffi_pk_op.cpp @@ -164,7 +164,7 @@ int botan_pk_op_verify_finish(botan_pk_op_verify_t op, const uint8_t sig[], size if(legit) return BOTAN_FFI_SUCCESS; else - return BOTAN_FFI_ERROR_INVALID_INPUT; + return BOTAN_FFI_INVALID_VERIFIER; }); } diff --git a/src/tests/test_ffi.cpp b/src/tests/test_ffi.cpp index 4a8e7b317..33be07cdf 100644 --- a/src/tests/test_ffi.cpp +++ b/src/tests/test_ffi.cpp @@ -1282,15 +1282,15 @@ class FFI_Unit_Tests : public Test // TODO: randomize this signature[0] ^= 1; TEST_FFI_OK(botan_pk_op_verify_update, (verifier, message.data(), message.size())); - TEST_FFI_FAIL("bad signature", botan_pk_op_verify_finish, (verifier, signature.data(), signature.size())); + TEST_FFI_RC(BOTAN_FFI_INVALID_VERIFIER, botan_pk_op_verify_finish, (verifier, signature.data(), signature.size())); message[0] ^= 1; TEST_FFI_OK(botan_pk_op_verify_update, (verifier, message.data(), message.size())); - TEST_FFI_FAIL("bad signature", botan_pk_op_verify_finish, (verifier, signature.data(), signature.size())); + TEST_FFI_RC(BOTAN_FFI_INVALID_VERIFIER, botan_pk_op_verify_finish, (verifier, signature.data(), signature.size())); signature[0] ^= 1; TEST_FFI_OK(botan_pk_op_verify_update, (verifier, message.data(), message.size())); - TEST_FFI_FAIL("bad signature", botan_pk_op_verify_finish, (verifier, signature.data(), signature.size())); + TEST_FFI_RC(BOTAN_FFI_INVALID_VERIFIER, botan_pk_op_verify_finish, (verifier, signature.data(), signature.size())); message[0] ^= 1; TEST_FFI_OK(botan_pk_op_verify_update, (verifier, message.data(), message.size())); @@ -1366,15 +1366,15 @@ class FFI_Unit_Tests : public Test // TODO: randomize this signature[0] ^= 1; TEST_FFI_OK(botan_pk_op_verify_update, (verifier, message.data(), message.size())); - TEST_FFI_FAIL("bad signature", botan_pk_op_verify_finish, (verifier, signature.data(), signature.size())); + TEST_FFI_RC(BOTAN_FFI_INVALID_VERIFIER, botan_pk_op_verify_finish, (verifier, signature.data(), signature.size())); message[0] ^= 1; TEST_FFI_OK(botan_pk_op_verify_update, (verifier, message.data(), message.size())); - TEST_FFI_FAIL("bad signature", botan_pk_op_verify_finish, (verifier, signature.data(), signature.size())); + TEST_FFI_RC(BOTAN_FFI_INVALID_VERIFIER, botan_pk_op_verify_finish, (verifier, signature.data(), signature.size())); signature[0] ^= 1; TEST_FFI_OK(botan_pk_op_verify_update, (verifier, message.data(), message.size())); - TEST_FFI_FAIL("bad signature", botan_pk_op_verify_finish, (verifier, signature.data(), signature.size())); + TEST_FFI_RC(BOTAN_FFI_INVALID_VERIFIER, botan_pk_op_verify_finish, (verifier, signature.data(), signature.size())); message[0] ^= 1; TEST_FFI_OK(botan_pk_op_verify_update, (verifier, message.data(), message.size())); @@ -1458,15 +1458,15 @@ class FFI_Unit_Tests : public Test // TODO: randomize this signature[0] ^= 1; TEST_FFI_OK(botan_pk_op_verify_update, (verifier, message.data(), message.size())); - TEST_FFI_FAIL("bad signature", botan_pk_op_verify_finish, (verifier, signature.data(), signature.size())); + TEST_FFI_RC(BOTAN_FFI_INVALID_VERIFIER, botan_pk_op_verify_finish, (verifier, signature.data(), signature.size())); message[0] ^= 1; TEST_FFI_OK(botan_pk_op_verify_update, (verifier, message.data(), message.size())); - TEST_FFI_FAIL("bad signature", botan_pk_op_verify_finish, (verifier, signature.data(), signature.size())); + TEST_FFI_RC(BOTAN_FFI_INVALID_VERIFIER, botan_pk_op_verify_finish, (verifier, signature.data(), signature.size())); signature[0] ^= 1; TEST_FFI_OK(botan_pk_op_verify_update, (verifier, message.data(), message.size())); - TEST_FFI_FAIL("bad signature", botan_pk_op_verify_finish, (verifier, signature.data(), signature.size())); + TEST_FFI_RC(BOTAN_FFI_INVALID_VERIFIER, botan_pk_op_verify_finish, (verifier, signature.data(), signature.size())); message[0] ^= 1; TEST_FFI_OK(botan_pk_op_verify_update, (verifier, message.data(), message.size())); |