Skip to content

Commit 3e56681

Browse files
committed
[crypto] Remove obsolete maximum output length method
Now that public-key algorithms use ASN.1 builders to dynamically allocate the output data, there is no further need for callers to be able to determine the maximum output length. Signed-off-by: Michael Brown <mcb30@ipxe.org>
1 parent 1ccc320 commit 3e56681

3 files changed

Lines changed: 0 additions & 40 deletions

File tree

src/crypto/crypto_null.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,6 @@ struct cipher_algorithm cipher_null = {
9393
.auth = cipher_null_auth,
9494
};
9595

96-
size_t pubkey_null_max_len ( const struct asn1_cursor *key __unused ) {
97-
return 0;
98-
}
99-
10096
int pubkey_null_encrypt ( const struct asn1_cursor *key __unused,
10197
const struct asn1_cursor *plaintext __unused,
10298
struct asn1_builder *ciphertext __unused ) {
@@ -125,7 +121,6 @@ int pubkey_null_verify ( const struct asn1_cursor *key __unused,
125121

126122
struct pubkey_algorithm pubkey_null = {
127123
.name = "null",
128-
.max_len = pubkey_null_max_len,
129124
.encrypt = pubkey_null_encrypt,
130125
.decrypt = pubkey_null_decrypt,
131126
.sign = pubkey_null_sign,

src/crypto/rsa.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -287,27 +287,6 @@ static int rsa_init ( struct rsa_context *context,
287287
return rc;
288288
}
289289

290-
/**
291-
* Calculate RSA maximum output length
292-
*
293-
* @v key Key
294-
* @ret max_len Maximum output length
295-
*/
296-
static size_t rsa_max_len ( const struct asn1_cursor *key ) {
297-
struct asn1_cursor modulus;
298-
struct asn1_cursor exponent;
299-
int rc;
300-
301-
/* Parse moduli and exponents */
302-
if ( ( rc = rsa_parse_mod_exp ( &modulus, &exponent, key ) ) != 0 ) {
303-
/* Return a zero maximum length on error */
304-
return 0;
305-
}
306-
307-
/* Output length can never exceed modulus length */
308-
return modulus.len;
309-
}
310-
311290
/**
312291
* Perform RSA cipher operation
313292
*
@@ -706,7 +685,6 @@ static int rsa_match ( const struct asn1_cursor *private_key,
706685
/** RSA public-key algorithm */
707686
struct pubkey_algorithm rsa_algorithm = {
708687
.name = "rsa",
709-
.max_len = rsa_max_len,
710688
.encrypt = rsa_encrypt,
711689
.decrypt = rsa_decrypt,
712690
.sign = rsa_sign,

src/include/ipxe/crypto.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,6 @@ struct cipher_algorithm {
121121
struct pubkey_algorithm {
122122
/** Algorithm name */
123123
const char *name;
124-
/** Calculate maximum output length
125-
*
126-
* @v key Key
127-
* @ret max_len Maximum output length
128-
*/
129-
size_t ( * max_len ) ( const struct asn1_cursor *key );
130124
/** Encrypt
131125
*
132126
* @v key Key
@@ -266,12 +260,6 @@ is_auth_cipher ( struct cipher_algorithm *cipher ) {
266260
return cipher->authsize;
267261
}
268262

269-
static inline __attribute__ (( always_inline )) size_t
270-
pubkey_max_len ( struct pubkey_algorithm *pubkey,
271-
const struct asn1_cursor *key ) {
272-
return pubkey->max_len ( key );
273-
}
274-
275263
static inline __attribute__ (( always_inline )) int
276264
pubkey_encrypt ( struct pubkey_algorithm *pubkey, const struct asn1_cursor *key,
277265
const struct asn1_cursor *plaintext,
@@ -325,7 +313,6 @@ extern void cipher_null_decrypt ( void *ctx, const void *src, void *dst,
325313
size_t len );
326314
extern void cipher_null_auth ( void *ctx, void *auth );
327315

328-
extern size_t pubkey_null_max_len ( const struct asn1_cursor *key );
329316
extern int pubkey_null_encrypt ( const struct asn1_cursor *key,
330317
const struct asn1_cursor *plaintext,
331318
struct asn1_builder *ciphertext );

0 commit comments

Comments
 (0)