From: Ian R. <iro...@us...> - 2006-11-13 12:11:13
|
Update of /cvsroot/perl-openssl/Crypt/OpenSSL/RSA In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2193 Modified Files: RSA.pm RSA.xs Log Message: *) Methods which say they can croak when called on a public key now actually croak instead of segfaulting. *) check_key is now documented to not work on public keys; it now croaks instead of segfaulting when called on a public key. *) Add an is_private method. Index: RSA.xs =================================================================== RCS file: /cvsroot/perl-openssl/Crypt/OpenSSL/RSA/RSA.xs,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** RSA.xs 12 Nov 2006 20:46:52 -0000 1.60 --- RSA.xs 13 Nov 2006 12:11:08 -0000 1.61 *************** *** 48,52 **** #define THROW(p_result) if (!(p_result)) { error = 1; goto err; } ! char is_private(rsaData* p_rsa) { return(p_rsa->rsa->d != NULL); --- 48,52 ---- #define THROW(p_result) if (!(p_result)) { error = 1; goto err; } ! char _is_private(rsaData* p_rsa) { return(p_rsa->rsa->d != NULL); *************** *** 412,415 **** --- 412,419 ---- SV* p_ciphertext; CODE: + if (!_is_private(p_rsa)) + { + croak("Public keys cannot decrypt"); + } RETVAL = rsa_crypt(p_rsa, p_ciphertext, RSA_private_decrypt); OUTPUT: *************** *** 421,424 **** --- 425,432 ---- SV* p_plaintext; CODE: + if (!_is_private(p_rsa)) + { + croak("Public keys cannot private_encrypt"); + } RETVAL = rsa_crypt(p_rsa, p_plaintext, RSA_private_encrypt); OUTPUT: *************** *** 446,449 **** --- 454,461 ---- rsaData* p_rsa; CODE: + if (!_is_private(p_rsa)) + { + croak("Public keys cannot be checked"); + } RETVAL = RSA_check_key(p_rsa->rsa); OUTPUT: *************** *** 557,561 **** CODE: { ! if (!is_private(p_rsa)) { croak("Public keys cannot sign messages."); --- 569,573 ---- CODE: { ! if (!_is_private(p_rsa)) { croak("Public keys cannot sign messages."); *************** *** 616,617 **** --- 628,637 ---- } } + + int + is_private(p_rsa) + rsaData* p_rsa; + CODE: + RETVAL = _is_private(p_rsa); + OUTPUT: + RETVAL Index: RSA.pm =================================================================== RCS file: /cvsroot/perl-openssl/Crypt/OpenSSL/RSA/RSA.pm,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** RSA.pm 13 Apr 2006 04:30:41 -0000 1.41 --- RSA.pm 13 Nov 2006 12:11:07 -0000 1.42 *************** *** 276,280 **** This function validates the RSA key, returning a true value if the key ! is valid, and a false value otherwise. =item get_key_parameters --- 276,280 ---- This function validates the RSA key, returning a true value if the key ! is valid, and a false value otherwise. Croaks if the key is public only. =item get_key_parameters *************** *** 287,290 **** --- 287,294 ---- be installed for this to work. + =item is_private + + Return true if this is a private key, and false if it is private only. + =cut |