fixed crash due to writing an unsupported key type

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-OpenPGP@5218 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2012-06-13 20:54:39 +00:00
parent 043c7a8139
commit 36bec260b9
2 changed files with 14 additions and 2 deletions

View file

@ -585,6 +585,12 @@ ops_boolean_t ops_write_struct_public_key(const ops_public_key_t *key,
{
assert(key->version == 4);
if(key->algorithm != OPS_PKA_RSA)
{
fprintf(stderr,"\nUnhandled key algorithm %d\n",key->algorithm);
return ops_false ;
}
return ops_write_ptag(OPS_PTAG_CT_PUBLIC_KEY,info)
&& ops_write_length(1+4+1+public_key_length(key),info)
&& write_public_key_body(key,info);
@ -905,7 +911,11 @@ ops_boolean_t encode_m_buf(const unsigned char *M, size_t mLen,
// implementation of EME-PKCS1-v1_5-ENCODE, as defined in OpenPGP RFC
assert(pkey->algorithm == OPS_PKA_RSA);
if(pkey->algorithm != OPS_PKA_RSA)
{
fprintf(stderr,"\nUnhandled key algorithm %d\n",pkey->algorithm);
return ops_false ;
}
k=BN_num_bytes(pkey->key.rsa.n);
assert(mLen <= k-11);