#include "fd.h"
#include "crypt_backend.h"
#include "base64.h"
+#include "portable_io.h"
struct asymmetric_key {
RSA *rsa;
return -E_BIGNUM;
if (p + 4 > end)
return -E_BIGNUM;
- bnsize = read_ssh_u32(p);
+ bnsize = read_u32_be(p);
PARA_DEBUG_LOG("bnsize: %u\n", bnsize);
p += 4;
if (p + bnsize < p)
#define AES_CRT128_BLOCK_SIZE 16
size_t is_ssh_rsa_key(char *data, size_t size);
-uint32_t read_ssh_u32(const void *vp);
int check_ssh_key_header(const unsigned char *blob, int blen);
int check_private_key_file(const char *file);
#include "string.h"
#include "crypt.h"
#include "crypt_backend.h"
+#include "portable_io.h"
/** If the key begins with this text, we treat it as an ssh key. */
#define KEY_TYPE_TXT "ssh-rsa"
return cp - data;
}
-/**
- * Read a 4-byte number from a buffer in big-endian format.
- *
- * \param vp The buffer.
- *
- * The byte-order of the buffer is expected to be big-endian, unlike read_u32()
- * of portable_io.h which expects little endian.
- *
- * \return The 32 bit number given by \a vp.
- */
-uint32_t read_ssh_u32(const void *vp)
-{
- const unsigned char *p = (const unsigned char *)vp;
- uint32_t v;
-
- v = (uint32_t)p[0] << 24;
- v |= (uint32_t)p[1] << 16;
- v |= (uint32_t)p[2] << 8;
- v |= (uint32_t)p[3];
-
- return v;
-}
-
/**
* Sanity checks for the header of an ssh key.
*
if (p + 4 > end)
return -E_SSH_KEY_HEADER;
- rlen = read_ssh_u32(p);
+ rlen = read_u32_be(p);
p += 4;
if (p + rlen < p)
return -E_SSH_KEY_HEADER;