Ver a proveniência

Have BIO_get_mem_data return a size_t and uint8_t*

Change-Id: I883f9c3527b572a2140ae4899cf4409cdc25c6dc
Reviewed-on: https://boringssl-review.googlesource.com/1261
Reviewed-by: Adam Langley <agl@google.com>
kris/onging/CECPQ3_patch15
Adam Langley há 10 anos
committed by Adam Langley
ascendente
cometimento
37a623cf29
5 ficheiros alterados com 35 adições e 15 eliminações
  1. +14
    -1
      crypto/bio/bio_mem.c
  2. +11
    -1
      include/openssl/bio.h
  3. +4
    -5
      ssl/s3_clnt.c
  4. +3
    -4
      ssl/s3_enc.c
  5. +3
    -4
      ssl/s3_srvr.c

+ 14
- 1
crypto/bio/bio_mem.c Ver ficheiro

@@ -254,7 +254,7 @@ static long mem_ctrl(BIO *bio, int cmd, long num, void *ptr) {
ret = (long)b->length;
if (ptr != NULL) {
pptr = (char **)ptr;
*pptr = (char *)&(b->data[0]);
*pptr = (char *)&b->data[0];
}
break;
case BIO_C_SET_BUF_MEM:
@@ -297,6 +297,19 @@ static const BIO_METHOD mem_method = {

const BIO_METHOD *BIO_s_mem(void) { return &mem_method; }

int BIO_mem_contents(const BIO *bio, const uint8_t **out_contents,
size_t *out_len) {
const BUF_MEM *b;
if (bio->method != &mem_method) {
return 0;
}

b = (BUF_MEM *)bio->ptr;
*out_contents = (uint8_t *)b->data;
*out_len = b->length;
return 1;
}

long BIO_get_mem_data(BIO *bio, char **contents) {
return BIO_ctrl(bio, BIO_CTRL_INFO, 0, (char *) contents);
}


+ 11
- 1
include/openssl/bio.h Ver ficheiro

@@ -358,8 +358,18 @@ const BIO_METHOD *BIO_s_mem(void);
* don't depend on this in new code. */
BIO *BIO_new_mem_buf(void *buf, int len);

/* BIO_mem_contents sets |*out_contents| to point to the current contents of
* |bio| and |*out_len| to contain the length of that data. It returns one on
* success and zero otherwise. */
int BIO_mem_contents(const BIO *bio, const uint8_t **out_contents,
size_t *out_len);

/* BIO_get_mem_data sets |*contents| to point to the current contents of |bio|
* and returns the length of the data. */
* and returns the length of the data.
*
* WARNING: don't use this, use |BIO_mem_contents|. A return value of zero from
* this function can mean either that it failed or that the memory buffer is
* empty. */
long BIO_get_mem_data(BIO *bio, char **contents);

/* BIO_get_mem_ptr sets |*out| to a BUF_MEM containing the current contents of


+ 4
- 5
ssl/s3_clnt.c Ver ficheiro

@@ -2587,12 +2587,11 @@ int ssl3_send_client_verify(SSL *s)
*/
if (SSL_USE_SIGALGS(s))
{
long hdatalen = 0;
char *hdata;
const uint8_t *hdata;
size_t hdatalen;
md = s->cert->key->digest;
hdatalen = BIO_get_mem_data(s->s3->handshake_buffer,
&hdata);
if (hdatalen <= 0 || !tls12_get_sigandhash(p, pkey, md))
if (!BIO_mem_contents(s->s3->handshake_buffer, &hdata, &hdatalen) ||
!tls12_get_sigandhash(p, pkey, md))
{
OPENSSL_PUT_ERROR(SSL, ssl3_send_client_verify, ERR_R_INTERNAL_ERROR);
goto err;


+ 3
- 4
ssl/s3_enc.c Ver ficheiro

@@ -552,15 +552,14 @@ int ssl3_digest_cached_records(SSL *s)
int i;
long mask;
const EVP_MD *md;
long hdatalen;
char *hdata;
const uint8_t *hdata;
size_t hdatalen;

/* Allocate handshake_dgst array */
ssl3_free_digest_list(s);
s->s3->handshake_dgst = OPENSSL_malloc(SSL_MAX_DIGEST * sizeof(EVP_MD_CTX *));
memset(s->s3->handshake_dgst,0,SSL_MAX_DIGEST *sizeof(EVP_MD_CTX *));
hdatalen = BIO_get_mem_data(s->s3->handshake_buffer,&hdata);
if (hdatalen <= 0)
if (!BIO_mem_contents(s->s3->handshake_buffer, &hdata, &hdatalen))
{
OPENSSL_PUT_ERROR(SSL, ssl3_digest_cached_records, SSL_R_BAD_HANDSHAKE_LENGTH);
return 0;


+ 3
- 4
ssl/s3_srvr.c Ver ficheiro

@@ -2702,10 +2702,9 @@ int ssl3_get_cert_verify(SSL *s)

if (SSL_USE_SIGALGS(s))
{
long hdatalen = 0;
char *hdata;
hdatalen = BIO_get_mem_data(s->s3->handshake_buffer, &hdata);
if (hdatalen <= 0)
size_t hdatalen;
const uint8_t *hdata;
if (!BIO_mem_contents(s->s3->handshake_buffer, &hdata, &hdatalen))
{
OPENSSL_PUT_ERROR(SSL, ssl3_get_cert_verify, ERR_R_INTERNAL_ERROR);
al=SSL_AD_INTERNAL_ERROR;


Carregando…
Cancelar
Guardar