Note that there are some explanatory texts on larger screens.

plurals
  1. POPrint unsigned int (base 10 / decimal) value of MPI
    primarykey
    data
    text
    <p>I'm trying to confirm/get the unsigned int (base 10 / decimal) value of an hex'd mpi value. I'm using the following code:</p> <pre><code>#include &lt;gcrypt.h&gt; #include &lt;stdio.h&gt; static gcry_mpi_t privkey = NULL; int main(){ char *parmstr = "48BFDA215C31A9F0B226B3DB11F862450A0F30DA"; printf("starting program\n"); gcry_mpi_scan(&amp;privkey, GCRYMPI_FMT_HEX, (char *)parmstr, 0, NULL); printf("printing hashed (?) mpi\n"); gcry_mpi_dump(privkey); printf("\n"); size_t gablen; unsigned char *result; /* get length */ gcry_mpi_print (GCRYMPI_FMT_USG, NULL, 0, &amp;gablen, privkey); result = gcry_malloc_secure(gablen); /* get actual value */ gcry_mpi_print (GCRYMPI_FMT_USG, result, gablen, NULL, privkey); /* print actual value */ printf("result: %s\n", result); printf("finished\n"); } </code></pre> <p>and i'm getting the following result:</p> <pre><code> $ ./foo starting program printing hashed (?) mpi 48BFDA215C31A9F0B226B3DB11F862450A0F30DA result: H¿Ú!\1©ð²&amp;³ÛøbE 0Ú finished </code></pre> <p>I would the 'result: ' line to print the actual unsigned int (base 10 / decimal) value.</p> <p>The private key is taking from the Off-The-Record Pidgin plug-in that i'm trying to work with.</p> <p><em>EDIT</em>:</p> <p>can anybody confirm that the actual unsigned int (base 10 / decimal) value should be</p> <blockquote> <p>415325779662433871844955547383752003988573073626</p> </blockquote> <p>I could probably update the program to create a new mpi in gcrypt with this value and see if the HEX value is the same as what i already have. I will do this later today.</p> <p><em>EDIT 2</em>:</p> <p>So i'm trying to do the following to print the HEX value of the int value mentioned above. Something is going wrong:</p> <pre><code>gcry_mpi_t cript_prime; char buffer[50] = {0}; char number[50] = {0}; cript_prime = gcry_mpi_new(50); strcpy(number,"415325779662433871844955547383752003988573073626"); gcry_mpi_scan(&amp;cript_prime,GCRYMPI_FMT_USG,number,sizeof(number),NULL); gcry_mpi_print(GCRYMPI_FMT_USG,buffer,sizeof(buffer),NULL,cript_prime); printf("The number tested is: %s\n",buffer); printf("trying to convert to HEX\n"); /* get actual value */ gcry_mpi_print (GCRYMPI_FMT_HEX, buffer, sizeof(buffer), NULL, cript_prime); /* print actual value */ printf("result: %s\n", buffer); </code></pre> <p>The output is:</p> <pre><code>result: 48BFDA215C31A9F0B226B3DB11F862450A0F30DA The number tested is: 415325779662433871844955547383752003988573073626 trying to convert to HEX result: 415325779662433871844955547383752003988573073626 </code></pre> <p><em>EDIT 3</em>:</p> <p>I updated the post a bit, basically i'm trying to print the base10 decimal value of an hex value that is generated by the gcrypt library. I'm looking for this value to confirm an implementation that i made to read these values. I was looking for a gcrypt function to achieve this. It seems that gcrypt doesn't supports this?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload