Explorar el Código

Compatibility changes for wpa_supplicant and OpenSSH.

OpenSSH, especially, does some terrible things that mean that it needs
the EVP_CIPHER structure to be exposed ☹. Damian is open to a better API
to replace this, but only if OpenSSL agree too. Either way, it won't be
happening soon.

Change-Id: I393b7a6af6694d4d2fe9ebcccd40286eff4029bd
Reviewed-on: https://boringssl-review.googlesource.com/4330
Reviewed-by: Adam Langley <agl@google.com>
kris/onging/CECPQ3_patch15
Adam Langley hace 9 años
padre
commit
c3ef76f327
Se han modificado 14 ficheros con 114 adiciones y 38 borrados
  1. +0
    -36
      crypto/cipher/internal.h
  2. +8
    -0
      crypto/crypto.c
  3. +10
    -0
      crypto/ec/ec.c
  4. +2
    -0
      crypto/ec/ec_key.c
  5. +4
    -0
      crypto/rand/rand.c
  6. +4
    -0
      crypto/rsa/rsa.c
  7. +2
    -2
      include/openssl/aes.h
  8. +36
    -0
      include/openssl/cipher.h
  9. +14
    -0
      include/openssl/crypto.h
  10. +16
    -0
      include/openssl/ec.h
  11. +6
    -0
      include/openssl/ec_key.h
  12. +3
    -0
      include/openssl/rand.h
  13. +6
    -0
      include/openssl/rsa.h
  14. +3
    -0
      include/openssl/ssl.h

+ 0
- 36
crypto/cipher/internal.h Ver fichero

@@ -66,42 +66,6 @@ extern "C" {
#endif


struct evp_cipher_st {
/* type contains a NID identifing the cipher. (e.g. NID_aes_128_gcm.) */
int nid;

/* block_size contains the block size, in bytes, of the cipher, or 1 for a
* stream cipher. */
unsigned block_size;

/* key_len contains the key size, in bytes, for the cipher. If the cipher
* takes a variable key size then this contains the default size. */
unsigned key_len;

/* iv_len contains the IV size, in bytes, or zero if inapplicable. */
unsigned iv_len;

/* ctx_size contains the size, in bytes, of the per-key context for this
* cipher. */
unsigned ctx_size;

/* flags contains the OR of a number of flags. See |EVP_CIPH_*|. */
uint32_t flags;

/* app_data is a pointer to opaque, user data. */
void *app_data;

int (*init)(EVP_CIPHER_CTX *ctx, const uint8_t *key, const uint8_t *iv,
int enc);

int (*cipher)(EVP_CIPHER_CTX *ctx, uint8_t *out, const uint8_t *in,
size_t inl);

void (*cleanup)(EVP_CIPHER_CTX *);

int (*ctrl)(EVP_CIPHER_CTX *, int type, int arg, void *ptr);
};

/* EVP_CIPH_MODE_MASK contains the bits of |flags| that represent the mode. */
#define EVP_CIPH_MODE_MASK 0x3f



+ 8
- 0
crypto/crypto.c Ver fichero

@@ -102,3 +102,11 @@ void CRYPTO_library_init(void) {
do_library_init();
#endif
}

const char *SSLeay_version(int unused) {
return SSLeay();
}

const char *SSLeay(void) {
return "BoringSSL";
}

+ 10
- 0
crypto/ec/ec.c Ver fichero

@@ -861,3 +861,13 @@ int ec_point_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *po
return group->meth->point_set_Jprojective_coordinates_GFp(group, point, x, y,
z, ctx);
}

void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag) {}

const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group) {
return NULL;
}

int EC_METHOD_get_field_type(const EC_METHOD *meth) {
return NID_X9_62_prime_field;
}

+ 2
- 0
crypto/ec/ec_key.c Ver fichero

@@ -515,3 +515,5 @@ int EC_KEY_set_ex_data(EC_KEY *d, int idx, void *arg) {
void *EC_KEY_get_ex_data(const EC_KEY *d, int idx) {
return CRYPTO_get_ex_data(&d->ex_data, idx);
}

void EC_KEY_set_asn1_flag(EC_KEY *key, int flag) {}

+ 4
- 0
crypto/rand/rand.c Ver fichero

@@ -154,3 +154,7 @@ void RAND_add(const void *buf, int num, double entropy) {}
int RAND_poll(void) {
return 1;
}

int RAND_status(void) {
return 1;
}

+ 4
- 0
crypto/rsa/rsa.c Ver fichero

@@ -764,3 +764,7 @@ int RSA_private_transform(RSA *rsa, uint8_t *out, const uint8_t *in,

return RSA_default_method.private_transform(rsa, out, in, len);
}

int RSA_blinding_on(RSA *rsa, BN_CTX *ctx) {
return 1;
}

+ 2
- 2
include/openssl/aes.h Ver fichero

@@ -146,9 +146,9 @@ OPENSSL_EXPORT void AES_cfb128_encrypt(const uint8_t *in, uint8_t *out,
* Android they'll have no definition. */

OPENSSL_EXPORT int AES_wrap_key(AES_KEY *key, const uint8_t *iv, uint8_t *out,
const uint8_t *in, size_t in_len);
const uint8_t *in, unsigned in_len);
OPENSSL_EXPORT int AES_unwrap_key(AES_KEY *key, const uint8_t *iv, uint8_t *out,
const uint8_t *in, size_t in_len);
const uint8_t *in, unsigned in_len);


#if defined(__cplusplus)


+ 36
- 0
include/openssl/cipher.h Ver fichero

@@ -488,6 +488,42 @@ typedef struct evp_cipher_info_st {
unsigned char iv[EVP_MAX_IV_LENGTH];
} EVP_CIPHER_INFO;

struct evp_cipher_st {
/* type contains a NID identifing the cipher. (e.g. NID_aes_128_gcm.) */
int nid;

/* block_size contains the block size, in bytes, of the cipher, or 1 for a
* stream cipher. */
unsigned block_size;

/* key_len contains the key size, in bytes, for the cipher. If the cipher
* takes a variable key size then this contains the default size. */
unsigned key_len;

/* iv_len contains the IV size, in bytes, or zero if inapplicable. */
unsigned iv_len;

/* ctx_size contains the size, in bytes, of the per-key context for this
* cipher. */
unsigned ctx_size;

/* flags contains the OR of a number of flags. See |EVP_CIPH_*|. */
uint32_t flags;

/* app_data is a pointer to opaque, user data. */
void *app_data;

int (*init)(EVP_CIPHER_CTX *ctx, const uint8_t *key, const uint8_t *iv,
int enc);

int (*cipher)(EVP_CIPHER_CTX *ctx, uint8_t *out, const uint8_t *in,
size_t inl);

void (*cleanup)(EVP_CIPHER_CTX *);

int (*ctrl)(EVP_CIPHER_CTX *, int type, int arg, void *ptr);
};


/* Android compatibility section.
*


+ 14
- 0
include/openssl/crypto.h Ver fichero

@@ -32,6 +32,20 @@ extern "C" {
OPENSSL_EXPORT void CRYPTO_library_init(void);


/* Deprecated functions. */

#define OPENSSL_VERSION_TEXT "BoringSSL"

#define SSLEAY_VERSION 0

/* SSLeay_version is a compatibility function that returns the string
* "BoringSSL". */
OPENSSL_EXPORT const char *SSLeay_version(int unused);

/* SSLeay is a compatibility function that returns the string "BoringSSL". */
OPENSSL_EXPORT const char *SSLeay(void);


#if defined(__cplusplus)
} /* extern C */
#endif


+ 16
- 0
include/openssl/ec.h Ver fichero

@@ -284,6 +284,22 @@ OPENSSL_EXPORT int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r,
BN_CTX *ctx);


/* Deprecated functions. */

/* EC_GROUP_set_asn1_flag does nothing. */
OPENSSL_EXPORT void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag);

#define OPENSSL_EC_NAMED_CURVE 0

typedef struct ec_method_st EC_METHOD;

/* EC_GROUP_method_of returns NULL. */
OPENSSL_EXPORT const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group);

/* EC_METHOD_get_field_type returns NID_X9_62_prime_field. */
OPENSSL_EXPORT int EC_METHOD_get_field_type(const EC_METHOD *meth);


/* Old code expects to get EC_KEY from ec.h. */
#if !defined(OPENSSL_HEADER_EC_KEY_H)
#include <openssl/ec_key.h>


+ 6
- 0
include/openssl/ec_key.h Ver fichero

@@ -273,6 +273,12 @@ struct ecdsa_method_st {
};


/* Deprecated functions. */

/* EC_KEY_set_asn1_flag does nothing. */
OPENSSL_EXPORT void EC_KEY_set_asn1_flag(EC_KEY *key, int flag);


#if defined(__cplusplus)
} /* extern C */
#endif


+ 3
- 0
include/openssl/rand.h Ver fichero

@@ -47,6 +47,9 @@ OPENSSL_EXPORT void RAND_add(const void *buf, int num, double entropy);
/* RAND_poll returns one. */
OPENSSL_EXPORT int RAND_poll(void);

/* RAND_status returns one. */
OPENSSL_EXPORT int RAND_status(void);


#if defined(__cplusplus)
} /* extern C */


+ 6
- 0
include/openssl/rsa.h Ver fichero

@@ -390,6 +390,12 @@ OPENSSL_EXPORT void *RSA_get_ex_data(const RSA *r, int idx);
#define RSA_F4 0x10001


/* Deprecated functions. */

/* RSA_blinding_on returns one. */
OPENSSL_EXPORT int RSA_blinding_on(RSA *rsa, BN_CTX *ctx);


struct rsa_meth_st {
struct openssl_method_common_st common;



+ 3
- 0
include/openssl/ssl.h Ver fichero

@@ -159,6 +159,9 @@
/* Some code expected to get the threading functions by including ssl.h. */
#include <openssl/thread.h>

/* wpa_supplicant expects to get the version functions from ssl.h */
#include <openssl/crypto.h>

#if defined(__cplusplus)
extern "C" {
#endif


Cargando…
Cancelar
Guardar