The function is supposed to return the key size in bytes, but it
returns the number of *bits*. A consequence of this bug is that
RSA keys which are too short to encrypt our 128 byte buffer are not
rejected as they should be. This is not too serious because we'll fail
later during the encryption step. Fix the bug anyway and clarify the
documentation of apc_get_pubkey().
* \param key_file The file containing the key.
* \param result The key structure is returned here.
*
- * \return The size of the key on success, negative on errors.
+ * \return The size of the key in bytes on success, negative on errors.
*/
int apc_get_pubkey(const char *key_file, struct asymmetric_key **result);
key->num_bytes = ret;
key->sexp = sexp;
*result = key;
- ret = bits;
+ ret = bits / 8;
release_n:
gcry_mpi_release(n);
release_e: