]> git.neil.brown.name Git - history.git/commitdiff
[CRYPTO]: Add null algorithms and minor cleanups.
authorJames Morris <jmorris@intercode.com.au>
Mon, 18 Nov 2002 16:00:26 +0000 (08:00 -0800)
committerJeff Garzik <jgarzik@redhat.com>
Mon, 18 Nov 2002 16:00:26 +0000 (08:00 -0800)
Documentation/crypto/api-intro.txt
crypto/Kconfig
crypto/Makefile
crypto/api.c
crypto/compress.c
include/linux/crypto.h

index b8cc036cac32f24579ab0c15227f17ea62dd71a2..f2e42883bdb5be3cf6a5de203c86d344901602cf 100644 (file)
@@ -73,6 +73,13 @@ add the following line to /etc/modules.conf:
 
   alias des3_ede des
 
+The Null algorithms reside in the crypto_null module, so these lines
+should also be added:
+
+  alias cipher_null crypto_null
+  alias digest_null crypto_null
+  alias compress_null crypto_null
+
 
 DEVELOPER NOTES
 
index f09c10bcfe6b28a837692730a58526071cfae18a..b87a265717d6c0d9f59ac959024058eee49c5da5 100644 (file)
@@ -16,6 +16,12 @@ config CRYPTO_HMAC
          HMAC: Keyed-Hashing for Message Authentication (RFC2104).
          This is required for IPSec.
 
+config CRYPTO_NULL
+       tristate "Null algorithms"
+       depends on CRYPTO
+       help
+         These are 'Null' algorithms, used by IPsec, which do nothing.
+
 config CRYPTO_MD4
        tristate "MD4 digest algorithm"
        depends on CRYPTO
index bd8973bdd84dad9d7115f24f7ceeb9a55228e116..d94a470b3a9d76915de0073e97c86785cc6667fa 100644 (file)
@@ -9,6 +9,7 @@ autoload-crypto-$(CONFIG_KMOD) = autoload.o
 obj-$(CONFIG_CRYPTO) += api.o cipher.o digest.o compress.o $(autoload-crypto-y)
 
 obj-$(CONFIG_CRYPTO_HMAC) += hmac.o
+obj-$(CONFIG_CRYPTO_NULL) += crypto_null.o
 obj-$(CONFIG_CRYPTO_MD4) += md4.o
 obj-$(CONFIG_CRYPTO_MD5) += md5.o
 obj-$(CONFIG_CRYPTO_SHA1) += sha1.o
index 7657bd59eefa3fcb5900f7bc00944dad10165be9..0649c6ebb78136410a18e98e4b0d4f52b0656760 100644 (file)
@@ -63,7 +63,7 @@ static int crypto_init_flags(struct crypto_tfm *tfm, u32 flags)
        case CRYPTO_ALG_TYPE_DIGEST:
                return crypto_init_digest_flags(tfm, flags);
                
-       case CRYPTO_ALG_TYPE_COMP:
+       case CRYPTO_ALG_TYPE_COMPRESS:
                return crypto_init_compress_flags(tfm, flags);
        
        default:
@@ -83,7 +83,7 @@ static int crypto_init_ops(struct crypto_tfm *tfm)
        case CRYPTO_ALG_TYPE_DIGEST:
                return crypto_init_digest_ops(tfm);
                
-       case CRYPTO_ALG_TYPE_COMP:
+       case CRYPTO_ALG_TYPE_COMPRESS:
                return crypto_init_compress_ops(tfm);
        
        default:
index 773fc5764050175ae3f43a7936384b234426ebc5..7baaae0479418017a2709bdf91a53a99bfb04547 100644 (file)
 #include <linux/string.h>
 #include "internal.h"
 
-/*
- * This code currently implements blazingly fast and
- * lossless Quadruple ROT13 compression.
- */
 static void crypto_compress(struct crypto_tfm *tfm)
-{ }
+{
+       tfm->__crt_alg->cra_compress.coa_compress();
+}
 
 static void crypto_decompress(struct crypto_tfm *tfm)
-{ }
+{
+       tfm->__crt_alg->cra_compress.coa_decompress();
+}
 
 int crypto_init_compress_flags(struct crypto_tfm *tfm, u32 flags)
 {
index b3448683d02d186322a8861811ec984d79c864ea..960e54133e29fd26ab892972248f574f18eece2e 100644 (file)
@@ -29,7 +29,7 @@
 #define CRYPTO_ALG_TYPE_MASK           0x000000ff
 #define CRYPTO_ALG_TYPE_CIPHER         0x00000001
 #define CRYPTO_ALG_TYPE_DIGEST         0x00000002
-#define CRYPTO_ALG_TYPE_COMP           0x00000004
+#define CRYPTO_ALG_TYPE_COMPRESS       0x00000004
 
 
 /*
@@ -209,16 +209,19 @@ static inline u32 crypto_tfm_alg_type(struct crypto_tfm *tfm)
 
 static inline unsigned int crypto_tfm_alg_min_keysize(struct crypto_tfm *tfm)
 {
+       BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
        return tfm->__crt_alg->cra_cipher.cia_min_keysize;
 }
 
 static inline unsigned int crypto_tfm_alg_max_keysize(struct crypto_tfm *tfm)
 {
+       BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
        return tfm->__crt_alg->cra_cipher.cia_max_keysize;
 }
 
 static inline unsigned int crypto_tfm_alg_ivsize(struct crypto_tfm *tfm)
 {
+       BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
        return tfm->__crt_alg->cra_cipher.cia_ivsize;
 }
 
@@ -229,6 +232,7 @@ static inline unsigned int crypto_tfm_alg_blocksize(struct crypto_tfm *tfm)
 
 static inline unsigned int crypto_tfm_alg_digestsize(struct crypto_tfm *tfm)
 {
+       BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST);
        return tfm->__crt_alg->cra_digest.dia_digestsize;
 }
 
@@ -302,13 +306,13 @@ static inline void crypto_cipher_get_iv(struct crypto_tfm *tfm,
 
 static inline void crypto_comp_compress(struct crypto_tfm *tfm)
 {
-       BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_COMP);
+       BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_COMPRESS);
        tfm->crt_compress.cot_compress(tfm);
 }
 
 static inline void crypto_comp_decompress(struct crypto_tfm *tfm) 
 {
-       BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_COMP);
+       BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_COMPRESS);
        tfm->crt_compress.cot_decompress(tfm);
 }