+static int read_openssh_bignum(unsigned char *start, unsigned char *end,
+ gcry_mpi_t *bn, unsigned *bitsp)
+{
+ gcry_error_t gret;
+ size_t nscanned;
+ unsigned bits;
+
+ gret = gcry_mpi_scan(bn, GCRYMPI_FMT_SSH, start, end - start, &nscanned);
+ if (gret) {
+ PARA_ERROR_LOG("gcry_mpi_scan: %s\n",
+ gcry_strerror(gcry_err_code(gret)));
+ return -E_MPI_SCAN;
+ }
+ bits = (nscanned - 4 - (start[4] == '\0')) * 8;
+ if (bitsp)
+ *bitsp = bits;
+ PARA_DEBUG_LOG("scanned %u-bit bignum\n", bits);
+ return nscanned;
+}
+