Add tests and fix bugs for RSA-alt contexts
diff --git a/library/pk.c b/library/pk.c
index 80eccc9..cfde265 100644
--- a/library/pk.c
+++ b/library/pk.c
@@ -258,6 +258,9 @@
     if( ctx == NULL || ctx->pk_info == NULL )
         return( POLARSSL_ERR_PK_BAD_INPUT_DATA );
 
+    if( ctx->pk_info->debug_func == NULL )
+        return( POLARSSL_ERR_PK_TYPE_MISMATCH );
+
     ctx->pk_info->debug_func( ctx->pk_ctx, items );
     return( 0 );
 }
diff --git a/library/pk_wrap.c b/library/pk_wrap.c
index 99535d6..96695d4 100644
--- a/library/pk_wrap.c
+++ b/library/pk_wrap.c
@@ -357,7 +357,7 @@
 {
     const rsa_alt_context *rsa_alt = (const rsa_alt_context *) ctx;
 
-    return( rsa_alt->key_len_func( rsa_alt->key ) );
+    return( 8 * rsa_alt->key_len_func( rsa_alt->key ) );
 }
 
 static int rsa_alt_sign_wrap( void *ctx, md_type_t md_alg,