Problems with mpi_getbyte

Matthias Frank Matthias.Frank at unibw-muenchen.de
Tue Jun 24 10:45:02 CEST 2003


Hello,

I'm currently playing around with GnuPG 1.2.2 (MinGW32) and
the iButton. I found @ cryptolabs.org some source-code
(including storing keys on the iButton)...
The Problem i have is the mpi_getbyte:

static int encode_mpi(
    unsigned char **bytes_out,
    int *bytes_len,
    MPI num_to_encode,
    unsigned char *bytes_buf,
    int bytes_buf_len
)
{
    int rc = 0;
    int i, byte_res;

    for (i = 0; ; i++) {
        byte_res = mpi_getbyte( num_to_encode, i ); // Here comes the
error
        if (byte_res == -1)
            break;
        if (i >= bytes_buf_len) {
            log_error( _("Key too big to send to iButton\n") );
            rc = G10ERR_GENERAL; // FIXME
            goto leave;
        }
        bytes_buf[bytes_buf_len - i -1] = byte_res;
    }

    *bytes_len = i;
    *bytes_out = bytes_buf + bytes_buf_len - i;
    if (*bytes_len == 0) {
            /* Encode a 0 specially */
        *--*bytes_out = '\0';
        *bytes_len = 1;
    }
  leave:
    return rc;
}

As soon as this function is called, it'll result
in an Application Error:

Gpg.exe - Fehler in Anwendung

Die Anweisung in "0x004920f1" verweist auf Speicher in
"0x000000d1". Der Vorgang "read" konnte nicht auf dem Speicher
durchgeführt werden.

I looked in the sourcecode, but couldn't find anything.

Greetz,
Matthias






More information about the Gnupg-devel mailing list