{
ret = _gnutls_mpi_dprint (session->key->KEY, &session->key->key);
}
- else /* In DHE_PSK the key is set differently */
+ else /* In DHE_PSK the key is set differently */
{
gnutls_datum_t tmp_dh_key;
ret = _gnutls_mpi_dprint (session->key->KEY, &tmp_dh_key);
{
ret = _gnutls_mpi_dprint (session->key->KEY, &session->key->key);
}
- else /* In DHE_PSK the key is set differently */
+ else /* In DHE_PSK the key is set differently */
{
gnutls_datum_t tmp_dh_key;
ret = _gnutls_mpi_dprint (session->key->KEY, &tmp_dh_key);
_gnutls_write_uint16 (n_X, &pdata[pos]);
- ret = data_size;
+ /* do not use data_size. _gnutls_mpi_print() might
+ * have been pessimist and might have returned initially
+ * more data */
+ ret = n_g + n_p + n_X + 6;
return ret;
}
ret = gcry_mpi_print (format, buffer, *nbytes, nbytes, a);
if (!ret) {
if (buffer==NULL || init_bytes < *nbytes) {
- (*nbytes)++;
+
+ /* in STD format we may want to include
+ * an extra byte for zero. Sometimes the gcry_
+ * function doesn't add it.
+ */
+ if (format == GNUTLS_MPI_FORMAT_STD) (*nbytes)++;
return GNUTLS_E_SHORT_MEMORY_BUFFER;
}
return 0;
if (buf == NULL)
return GNUTLS_E_MEMORY_ERROR;
- dest->size = MAX (size, bytes);
-
if (bytes <= size)
{
size_t diff = size - bytes;