Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: sig - Move crypto_sig_*() API calls to include file

The crypto_sig_*() API calls lived in sig.c so far because they needed
access to struct crypto_sig_type: This was necessary to differentiate
between signature algorithms that had already been migrated from
crypto_akcipher to crypto_sig and those that hadn't yet.

Now that all algorithms have been migrated, the API calls can become
static inlines in <crypto/sig.h> to mimic what <crypto/akcipher.h> is
doing.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Lukas Wunner and committed by
Herbert Xu
5ba29667 6b34562f

+36 -57
-46
crypto/sig.c
··· 84 84 } 85 85 EXPORT_SYMBOL_GPL(crypto_alloc_sig); 86 86 87 - int crypto_sig_maxsize(struct crypto_sig *tfm) 88 - { 89 - struct sig_alg *alg = crypto_sig_alg(tfm); 90 - 91 - return alg->max_size(tfm); 92 - } 93 - EXPORT_SYMBOL_GPL(crypto_sig_maxsize); 94 - 95 - int crypto_sig_sign(struct crypto_sig *tfm, 96 - const void *src, unsigned int slen, 97 - void *dst, unsigned int dlen) 98 - { 99 - struct sig_alg *alg = crypto_sig_alg(tfm); 100 - 101 - return alg->sign(tfm, src, slen, dst, dlen); 102 - } 103 - EXPORT_SYMBOL_GPL(crypto_sig_sign); 104 - 105 - int crypto_sig_verify(struct crypto_sig *tfm, 106 - const void *src, unsigned int slen, 107 - const void *digest, unsigned int dlen) 108 - { 109 - struct sig_alg *alg = crypto_sig_alg(tfm); 110 - 111 - return alg->verify(tfm, src, slen, digest, dlen); 112 - } 113 - EXPORT_SYMBOL_GPL(crypto_sig_verify); 114 - 115 - int crypto_sig_set_pubkey(struct crypto_sig *tfm, 116 - const void *key, unsigned int keylen) 117 - { 118 - struct sig_alg *alg = crypto_sig_alg(tfm); 119 - 120 - return alg->set_pub_key(tfm, key, keylen); 121 - } 122 - EXPORT_SYMBOL_GPL(crypto_sig_set_pubkey); 123 - 124 - int crypto_sig_set_privkey(struct crypto_sig *tfm, 125 - const void *key, unsigned int keylen) 126 - { 127 - struct sig_alg *alg = crypto_sig_alg(tfm); 128 - 129 - return alg->set_priv_key(tfm, key, keylen); 130 - } 131 - EXPORT_SYMBOL_GPL(crypto_sig_set_privkey); 132 - 133 87 static void sig_prepare_alg(struct sig_alg *alg) 134 88 { 135 89 struct crypto_alg *base = &alg->base;
+36 -11
include/crypto/sig.h
··· 130 130 * 131 131 * @tfm: signature tfm handle allocated with crypto_alloc_sig() 132 132 */ 133 - int crypto_sig_maxsize(struct crypto_sig *tfm); 133 + static inline int crypto_sig_maxsize(struct crypto_sig *tfm) 134 + { 135 + struct sig_alg *alg = crypto_sig_alg(tfm); 136 + 137 + return alg->max_size(tfm); 138 + } 134 139 135 140 /** 136 141 * crypto_sig_sign() - Invoke signing operation ··· 150 145 * 151 146 * Return: zero on success; error code in case of error 152 147 */ 153 - int crypto_sig_sign(struct crypto_sig *tfm, 154 - const void *src, unsigned int slen, 155 - void *dst, unsigned int dlen); 148 + static inline int crypto_sig_sign(struct crypto_sig *tfm, 149 + const void *src, unsigned int slen, 150 + void *dst, unsigned int dlen) 151 + { 152 + struct sig_alg *alg = crypto_sig_alg(tfm); 153 + 154 + return alg->sign(tfm, src, slen, dst, dlen); 155 + } 156 156 157 157 /** 158 158 * crypto_sig_verify() - Invoke signature verification ··· 173 163 * 174 164 * Return: zero on verification success; error code in case of error. 175 165 */ 176 - int crypto_sig_verify(struct crypto_sig *tfm, 177 - const void *src, unsigned int slen, 178 - const void *digest, unsigned int dlen); 166 + static inline int crypto_sig_verify(struct crypto_sig *tfm, 167 + const void *src, unsigned int slen, 168 + const void *digest, unsigned int dlen) 169 + { 170 + struct sig_alg *alg = crypto_sig_alg(tfm); 171 + 172 + return alg->verify(tfm, src, slen, digest, dlen); 173 + } 179 174 180 175 /** 181 176 * crypto_sig_set_pubkey() - Invoke set public key operation ··· 195 180 * 196 181 * Return: zero on success; error code in case of error 197 182 */ 198 - int crypto_sig_set_pubkey(struct crypto_sig *tfm, 199 - const void *key, unsigned int keylen); 183 + static inline int crypto_sig_set_pubkey(struct crypto_sig *tfm, 184 + const void *key, unsigned int keylen) 185 + { 186 + struct sig_alg *alg = crypto_sig_alg(tfm); 187 + 188 + return alg->set_pub_key(tfm, key, keylen); 189 + } 200 190 201 191 /** 202 192 * crypto_sig_set_privkey() - Invoke set private key operation ··· 216 196 * 217 197 * Return: zero on success; error code in case of error 218 198 */ 219 - int crypto_sig_set_privkey(struct crypto_sig *tfm, 220 - const void *key, unsigned int keylen); 199 + static inline int crypto_sig_set_privkey(struct crypto_sig *tfm, 200 + const void *key, unsigned int keylen) 201 + { 202 + struct sig_alg *alg = crypto_sig_alg(tfm); 203 + 204 + return alg->set_priv_key(tfm, key, keylen); 205 + } 221 206 #endif