Skip to content
openssl.c 89.8 KiB
Newer Older
#if(OPENSSL_VERSION_NUMBER >= 0x900000)
  return snprintf(buffer, size, "OpenSSL/%lx.%lx.%lx",
                  (OPENSSL_VERSION_NUMBER>>28)&0xff,
                  (OPENSSL_VERSION_NUMBER>>20)&0xff,
                  (OPENSSL_VERSION_NUMBER>>12)&0xf);
#else /* (OPENSSL_VERSION_NUMBER >= 0x900000) */
    if(OPENSSL_VERSION_NUMBER&0x0f) {
      sub[0]=(OPENSSL_VERSION_NUMBER&0x0f) + 'a' -1;
    return snprintf(buffer, size, "SSL/%x.%x.%x%s",
                    (OPENSSL_VERSION_NUMBER>>12)&0xff,
                    (OPENSSL_VERSION_NUMBER>>8)&0xf,
                    (OPENSSL_VERSION_NUMBER>>4)&0xf, sub);
#endif /* (OPENSSL_VERSION_NUMBER >= 0x900000) */
#endif /* OPENSSL_VERSION_NUMBER is less than 0.9.5 */
Leith Bade's avatar
Leith Bade committed
#endif /* OPENSSL_IS_BORINGSSL */
/* can be called with data == NULL */
int Curl_ossl_random(struct SessionHandle *data, unsigned char *entropy,
                     size_t length)
Leith Bade's avatar
Leith Bade committed
  if(data) {
    Curl_ossl_seed(data); /* Initiate the seed if not already done */
Leith Bade's avatar
Leith Bade committed
  }
  RAND_bytes(entropy, curlx_uztosi(length));
  return 0; /* 0 as in no problem */
}

void Curl_ossl_md5sum(unsigned char *tmp, /* input */
                      size_t tmplen,
                      unsigned char *md5sum /* output */,
                      size_t unused)
{
  MD5_CTX MD5pw;
  (void)unused;
  MD5_Init(&MD5pw);
  MD5_Update(&MD5pw, tmp, tmplen);
  MD5_Final(md5sum, &MD5pw);
}
#if (OPENSSL_VERSION_NUMBER >= 0x0090800fL) && !defined(OPENSSL_NO_SHA256)
void Curl_ossl_sha256sum(const unsigned char *tmp, /* input */
                      size_t tmplen,
                      unsigned char *sha256sum /* output */,
                      size_t unused)
{
  SHA256_CTX SHA256pw;
  (void)unused;
  SHA256_Init(&SHA256pw);
  SHA256_Update(&SHA256pw, tmp, tmplen);
  SHA256_Final(sha256sum, &SHA256pw);
}
bool Curl_ossl_cert_status_request(void)
{
#if (OPENSSL_VERSION_NUMBER >= 0x0090808fL) && !defined(OPENSSL_NO_TLSEXT) && \
    !defined(OPENSSL_IS_BORINGSSL)
#endif /* USE_OPENSSL */