/* * Retrieves a BIGNUM from the buffer. */ int buffer_get_bignum_ret(Buffer *buffer, BIGNUM *value) { u_int bits, bytes; u_char buf[2], *bin; /* Get the number of bits. */ if (buffer_get_ret(buffer, (char *) buf, 2) == -1) { error("buffer_get_bignum_ret: invalid length"); return (-1); } bits = get_u16(buf); /* Compute the number of binary bytes that follow. */ bytes = (bits + 7) / 8; if (bytes > 8 * 1024) { error("buffer_get_bignum_ret: cannot handle BN of size %d", bytes); return (-1); } if (buffer_len(buffer) < bytes) { error("buffer_get_bignum_ret: input buffer too small"); return (-1); } bin = buffer_ptr(buffer); if (BN_bin2bn(bin, bytes, value) == NULL) { error("buffer_get_bignum_ret: BN_bin2bn failed"); return (-1); } if (buffer_consume_ret(buffer, bytes) == -1) { error("buffer_get_bignum_ret: buffer_consume failed"); return (-1); } return (0); }
void buffer_consume(Buffer *buffer, u_int bytes) { if (buffer_consume_ret(buffer, bytes) == -1) fatal("buffer_consume: buffer error"); }
void buffer_consume(Buffer *buffer, u_int bytes) { if (buffer_consume_ret(buffer, bytes) == -1) fatal("%s: buffer error", __func__); }
void buffer_consume(Buffer *buffer, uint32_t bytes) { if (buffer_consume_ret(buffer, bytes) == -1) croak("buffer_consume: buffer error"); }