Skip to content

Instantly share code, notes, and snippets.

@robUx4
Created June 21, 2018 09:22
Show Gist options
  • Save robUx4/7a772f00d3d01582d358d147bcd7e1f8 to your computer and use it in GitHub Desktop.
Save robUx4/7a772f00d3d01582d358d147bcd7e1f8 to your computer and use it in GitHub Desktop.
line 146
/* Make sure that the opaque MPI VALUE is in compact EdDSA format.
This function updates MPI if needed. */
gpg_err_code_t
_gcry_ecc_eddsa_ensure_compact (gcry_mpi_t value, unsigned int nbits)
{
gpg_err_code_t rc;
const unsigned char *buf;
unsigned int rawmpilen;
gcry_mpi_t x, y;
unsigned char *enc;
unsigned int enclen;
if (!mpi_is_opaque (value))
return GPG_ERR_INV_OBJ;
buf = mpi_get_opaque (value, &rawmpilen);
if (!buf)
return GPG_ERR_INV_OBJ;
rawmpilen = (rawmpilen + 7)/8;
if (rawmpilen > 1 && (rawmpilen%2))
{
if (buf[0] == 0x04)
{
/* Buffer is in SEC1 uncompressed format. Extract y and
compress. */
rc = _gcry_mpi_scan (&x, GCRYMPI_FMT_STD,
buf+1, (rawmpilen-1)/2, NULL);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment