Procházet zdrojové kódy

Add a size hook to RSA_METHOD.

This is to avoid having to copy over the RSA modulus in all of Chromium's
platform-specific keys.

Change-Id: I20bf22446a5cfb633b900c3b392b7a1da81a5431
Reviewed-on: https://boringssl-review.googlesource.com/1151
Reviewed-by: Adam Langley <agl@google.com>
kris/onging/CECPQ3_patch15
David Benjamin před 10 roky
committed by Adam Langley
rodič
revize
925fee36e1
3 změnil soubory, kde provedl 14 přidání a 1 odebrání
  1. +5
    -1
      crypto/rsa/rsa.c
  2. +3
    -0
      crypto/rsa/rsa.h
  3. +6
    -0
      crypto/rsa/rsa_impl.c

+ 5
- 1
crypto/rsa/rsa.c Zobrazit soubor

@@ -249,7 +249,11 @@ int RSA_public_decrypt(int flen, const uint8_t *from, uint8_t *to, RSA *rsa,
}

unsigned RSA_size(const RSA *rsa) {
return BN_num_bytes(rsa->n);
if (rsa->meth->size) {
return rsa->meth->size(rsa);
}

return RSA_default_method.size(rsa);
}

int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,


+ 3
- 0
crypto/rsa/rsa.h Zobrazit soubor

@@ -328,6 +328,9 @@ struct rsa_meth_st {
int (*init)(RSA *rsa);
int (*finish)(RSA *rsa);

/* size returns the size of the RSA modulus in bytes. */
size_t (*size)(const RSA *rsa);

int (*sign)(int type, const uint8_t *m, unsigned int m_length,
uint8_t *sigret, unsigned int *siglen, const RSA *rsa);



+ 6
- 0
crypto/rsa/rsa_impl.c Zobrazit soubor

@@ -83,6 +83,10 @@ static int finish(RSA *rsa) {
return 1;
}

static size_t size(const RSA *rsa) {
return BN_num_bytes(rsa->n);
}

static int encrypt(RSA *rsa, size_t *out_len, uint8_t *out, size_t max_out,
const uint8_t *in, size_t in_len, int padding) {
const unsigned rsa_size = RSA_size(rsa);
@@ -992,6 +996,8 @@ const struct rsa_meth_st RSA_default_method = {
NULL /* init */,
finish,

size,

NULL /* sign */,
NULL /* verify */,



Načítá se…
Zrušit
Uložit