Skip to content

Commit

Permalink
fixed segmentation fault on macosx64
Browse files Browse the repository at this point in the history
  • Loading branch information
mkaydev committed Jan 24, 2012
1 parent 33b77bd commit dd47406
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
5 changes: 4 additions & 1 deletion client/usermode/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,11 @@ def verify_signature(signing_cert_path, signed_data, signature):
# signed_data : raw package data (bytes) which were signed to create
# the signature
# signature : supposedly rsa_pkcs1_1.5 signature over sha1(signed_data)
signing_cert_path = _format_to_bytes(signing_cert_path)
signature = bytes(signature)
signed_data = bytes(signed_data)

signed = _verify_signature(_format_to_bytes(signing_cert_path),
signed = _verify_signature(signing_cert_path,
signature,
signed_data,
len(signed_data))
Expand Down
Binary file modified client/usermode/security/lib/MacOS/ia32/libsecurity.dylib
Binary file not shown.
Binary file modified client/usermode/security/lib/MacOS/x64/libsecurity.dylib
Binary file not shown.
12 changes: 6 additions & 6 deletions client/usermode/security/src/security.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ int verify_signature(const char* certfile, unsigned char* signature, const unsig
int keysize;
int ret = 0;
const EVP_MD *digest_algorithm;
EVP_MD_CTX ctx;
EVP_MD_CTX *ctx;
unsigned char digest[EVP_MAX_MD_SIZE];
int digest_length;
int rsa_out_length;
Expand Down Expand Up @@ -101,11 +101,11 @@ int verify_signature(const char* certfile, unsigned char* signature, const unsig

keysize = RSA_size(rsa);
digest_algorithm = EVP_sha1();
EVP_MD_CTX_init(&ctx);
EVP_DigestInit_ex(&ctx, digest_algorithm, NULL);
EVP_DigestUpdate(&ctx, signed_data, signed_data_length);
EVP_DigestFinal_ex(&ctx, digest, &digest_length);
EVP_MD_CTX_cleanup(&ctx);
ctx = EVP_MD_CTX_create();
EVP_DigestInit_ex(ctx, digest_algorithm, NULL);
EVP_DigestUpdate(ctx, signed_data, signed_data_length);
EVP_DigestFinal_ex(ctx, digest, &digest_length);
EVP_MD_CTX_cleanup(ctx);

rsa_out = OPENSSL_malloc(keysize);
rsa_out_length = RSA_public_decrypt(keysize,signature,rsa_out,rsa,RSA_PKCS1_PADDING);
Expand Down
4 changes: 4 additions & 0 deletions client/usermode/test/test_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,7 @@ def run_tests():
test_verify_cert()
test_verify_signature()

if __name__ == "__main__":
run_tests()
print("Done.")

0 comments on commit dd47406

Please sign in to comment.