]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[crypto] Remove obsolete maximum output length method
authorMichael Brown <mcb30@ipxe.org>
Tue, 2 Dec 2025 13:13:01 +0000 (13:13 +0000)
committerMichael Brown <mcb30@ipxe.org>
Tue, 2 Dec 2025 13:13:01 +0000 (13:13 +0000)
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>
src/crypto/crypto_null.c
src/crypto/rsa.c
src/include/ipxe/crypto.h

index e8f8cbde8ed01dbe5aeb2b588d957b365af4a764..e80f2707f7bbde698cde549a9a700cbcb7e6c725 100644 (file)
@@ -93,10 +93,6 @@ struct cipher_algorithm cipher_null = {
        .auth = cipher_null_auth,
 };
 
-size_t pubkey_null_max_len ( const struct asn1_cursor *key __unused ) {
-       return 0;
-}
-
 int pubkey_null_encrypt ( const struct asn1_cursor *key __unused,
                          const struct asn1_cursor *plaintext __unused,
                          struct asn1_builder *ciphertext __unused ) {
@@ -125,7 +121,6 @@ int pubkey_null_verify ( const struct asn1_cursor *key __unused,
 
 struct pubkey_algorithm pubkey_null = {
        .name = "null",
-       .max_len = pubkey_null_max_len,
        .encrypt = pubkey_null_encrypt,
        .decrypt = pubkey_null_decrypt,
        .sign = pubkey_null_sign,
index 18b2b1c1479834372a48ba474d1c4681202a4e02..051bbfa087fa58e039148e4689616c95e2aca425 100644 (file)
@@ -287,27 +287,6 @@ static int rsa_init ( struct rsa_context *context,
        return rc;
 }
 
-/**
- * Calculate RSA maximum output length
- *
- * @v key              Key
- * @ret max_len                Maximum output length
- */
-static size_t rsa_max_len ( const struct asn1_cursor *key ) {
-       struct asn1_cursor modulus;
-       struct asn1_cursor exponent;
-       int rc;
-
-       /* Parse moduli and exponents */
-       if ( ( rc = rsa_parse_mod_exp ( &modulus, &exponent, key ) ) != 0 ) {
-               /* Return a zero maximum length on error */
-               return 0;
-       }
-
-       /* Output length can never exceed modulus length */
-       return modulus.len;
-}
-
 /**
  * Perform RSA cipher operation
  *
@@ -706,7 +685,6 @@ static int rsa_match ( const struct asn1_cursor *private_key,
 /** RSA public-key algorithm */
 struct pubkey_algorithm rsa_algorithm = {
        .name           = "rsa",
-       .max_len        = rsa_max_len,
        .encrypt        = rsa_encrypt,
        .decrypt        = rsa_decrypt,
        .sign           = rsa_sign,
index 68bd230482d6ee012599dcd63e7132bd5a539b5d..ee63423c939bcff7763a24dad580b2886b9e7f35 100644 (file)
@@ -121,12 +121,6 @@ struct cipher_algorithm {
 struct pubkey_algorithm {
        /** Algorithm name */
        const char *name;
-       /** Calculate maximum output length
-        *
-        * @v key               Key
-        * @ret max_len         Maximum output length
-        */
-       size_t ( * max_len ) ( const struct asn1_cursor *key );
        /** Encrypt
         *
         * @v key               Key
@@ -266,12 +260,6 @@ is_auth_cipher ( struct cipher_algorithm *cipher ) {
        return cipher->authsize;
 }
 
-static inline __attribute__ (( always_inline )) size_t
-pubkey_max_len ( struct pubkey_algorithm *pubkey,
-                const struct asn1_cursor *key ) {
-       return pubkey->max_len ( key );
-}
-
 static inline __attribute__ (( always_inline )) int
 pubkey_encrypt ( struct pubkey_algorithm *pubkey, const struct asn1_cursor *key,
                 const struct asn1_cursor *plaintext,
@@ -325,7 +313,6 @@ extern void cipher_null_decrypt ( void *ctx, const void *src, void *dst,
                                  size_t len );
 extern void cipher_null_auth ( void *ctx, void *auth );
 
-extern size_t pubkey_null_max_len ( const struct asn1_cursor *key );
 extern int pubkey_null_encrypt ( const struct asn1_cursor *key,
                                 const struct asn1_cursor *plaintext,
                                 struct asn1_builder *ciphertext );