[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/opencrypto/xform.c

Version: -  FREEBSD  -  FREEBSD10  -  FREEBSD9  -  FREEBSD92  -  FREEBSD91  -  FREEBSD90  -  FREEBSD8  -  FREEBSD82  -  FREEBSD81  -  FREEBSD80  -  FREEBSD7  -  FREEBSD74  -  FREEBSD73  -  FREEBSD72  -  FREEBSD71  -  FREEBSD70  -  FREEBSD6  -  FREEBSD64  -  FREEBSD63  -  FREEBSD62  -  FREEBSD61  -  FREEBSD60  -  FREEBSD5  -  FREEBSD55  -  FREEBSD54  -  FREEBSD53  -  FREEBSD52  -  FREEBSD51  -  FREEBSD50  -  FREEBSD4  -  FREEBSD3  -  FREEBSD22  -  cheribsd  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1  -  FREEBSD-LIBC  -  FREEBSD8-LIBC  -  FREEBSD7-LIBC  -  FREEBSD6-LIBC  -  GLIBC27 
SearchContext: -  none  -  3  -  10 

    1 /*      $OpenBSD: xform.c,v 1.16 2001/08/28 12:20:43 ben Exp $  */
    2 /*-
    3  * The authors of this code are John Ioannidis (ji@tla.org),
    4  * Angelos D. Keromytis (kermit@csd.uch.gr) and
    5  * Niels Provos (provos@physnet.uni-hamburg.de).
    6  *
    7  * This code was written by John Ioannidis for BSD/OS in Athens, Greece,
    8  * in November 1995.
    9  *
   10  * Ported to OpenBSD and NetBSD, with additional transforms, in December 1996,
   11  * by Angelos D. Keromytis.
   12  *
   13  * Additional transforms and features in 1997 and 1998 by Angelos D. Keromytis
   14  * and Niels Provos.
   15  *
   16  * Additional features in 1999 by Angelos D. Keromytis.
   17  *
   18  * Copyright (C) 1995, 1996, 1997, 1998, 1999 by John Ioannidis,
   19  * Angelos D. Keromytis and Niels Provos.
   20  *
   21  * Copyright (C) 2001, Angelos D. Keromytis.
   22  *
   23  * Permission to use, copy, and modify this software with or without fee
   24  * is hereby granted, provided that this entire notice is included in
   25  * all copies of any software which is or includes a copy or
   26  * modification of this software.
   27  * You may use this code under the GNU public license if you so wish. Please
   28  * contribute changes back to the authors under this freer than GPL license
   29  * so that we may further the use of strong encryption without limitations to
   30  * all.
   31  *
   32  * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
   33  * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
   34  * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
   35  * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
   36  * PURPOSE.
   37  */
   38 
   39 #include <sys/cdefs.h>
   40 __FBSDID("$FreeBSD: src/sys/opencrypto/xform.c,v 1.2.4.1 2005/01/31 23:26:48 imp Exp $");
   41 
   42 #include <sys/param.h>
   43 #include <sys/systm.h>
   44 #include <sys/malloc.h>
   45 #include <sys/sysctl.h>
   46 #include <sys/errno.h>
   47 #include <sys/time.h>
   48 #include <sys/kernel.h>
   49 #include <machine/cpu.h>
   50 
   51 #include <crypto/blowfish/blowfish.h>
   52 #include <crypto/des/des.h>
   53 #include <crypto/sha1.h>
   54 
   55 #include <opencrypto/cast.h>
   56 #include <opencrypto/deflate.h>
   57 #include <opencrypto/rijndael.h>
   58 #include <opencrypto/rmd160.h>
   59 #include <opencrypto/skipjack.h>
   60 
   61 #include <sys/md5.h>
   62 
   63 #include <opencrypto/cryptodev.h>
   64 #include <opencrypto/xform.h>
   65 
   66 static void null_encrypt(caddr_t, u_int8_t *);
   67 static void null_decrypt(caddr_t, u_int8_t *);
   68 static int null_setkey(u_int8_t **, u_int8_t *, int);
   69 static void null_zerokey(u_int8_t **);
   70 
   71 static  int des1_setkey(u_int8_t **, u_int8_t *, int);
   72 static  int des3_setkey(u_int8_t **, u_int8_t *, int);
   73 static  int blf_setkey(u_int8_t **, u_int8_t *, int);
   74 static  int cast5_setkey(u_int8_t **, u_int8_t *, int);
   75 static  int skipjack_setkey(u_int8_t **, u_int8_t *, int);
   76 static  int rijndael128_setkey(u_int8_t **, u_int8_t *, int);
   77 static  void des1_encrypt(caddr_t, u_int8_t *);
   78 static  void des3_encrypt(caddr_t, u_int8_t *);
   79 static  void blf_encrypt(caddr_t, u_int8_t *);
   80 static  void cast5_encrypt(caddr_t, u_int8_t *);
   81 static  void skipjack_encrypt(caddr_t, u_int8_t *);
   82 static  void rijndael128_encrypt(caddr_t, u_int8_t *);
   83 static  void des1_decrypt(caddr_t, u_int8_t *);
   84 static  void des3_decrypt(caddr_t, u_int8_t *);
   85 static  void blf_decrypt(caddr_t, u_int8_t *);
   86 static  void cast5_decrypt(caddr_t, u_int8_t *);
   87 static  void skipjack_decrypt(caddr_t, u_int8_t *);
   88 static  void rijndael128_decrypt(caddr_t, u_int8_t *);
   89 static  void des1_zerokey(u_int8_t **);
   90 static  void des3_zerokey(u_int8_t **);
   91 static  void blf_zerokey(u_int8_t **);
   92 static  void cast5_zerokey(u_int8_t **);
   93 static  void skipjack_zerokey(u_int8_t **);
   94 static  void rijndael128_zerokey(u_int8_t **);
   95 
   96 static  void null_init(void *);
   97 static  int null_update(void *, u_int8_t *, u_int16_t);
   98 static  void null_final(u_int8_t *, void *);
   99 static  int MD5Update_int(void *, u_int8_t *, u_int16_t);
  100 static  void SHA1Init_int(void *);
  101 static  int SHA1Update_int(void *, u_int8_t *, u_int16_t);
  102 static  void SHA1Final_int(u_int8_t *, void *);
  103 static  int RMD160Update_int(void *, u_int8_t *, u_int16_t);
  104 static  int SHA256Update_int(void *, u_int8_t *, u_int16_t);
  105 static  int SHA384Update_int(void *, u_int8_t *, u_int16_t);
  106 static  int SHA512Update_int(void *, u_int8_t *, u_int16_t);
  107 
  108 static  u_int32_t deflate_compress(u_int8_t *, u_int32_t, u_int8_t **);
  109 static  u_int32_t deflate_decompress(u_int8_t *, u_int32_t, u_int8_t **);
  110 
  111 MALLOC_DEFINE(M_XDATA, "xform", "xform data buffers");
  112 
  113 /* Encryption instances */
  114 struct enc_xform enc_xform_null = {
  115         CRYPTO_NULL_CBC, "NULL",
  116         /* NB: blocksize of 4 is to generate a properly aligned ESP header */
  117         4, 0, 256, /* 2048 bits, max key */
  118         null_encrypt,
  119         null_decrypt,
  120         null_setkey,
  121         null_zerokey,
  122 };
  123 
  124 struct enc_xform enc_xform_des = {
  125         CRYPTO_DES_CBC, "DES",
  126         8, 8, 8,
  127         des1_encrypt,
  128         des1_decrypt,
  129         des1_setkey,
  130         des1_zerokey,
  131 };
  132 
  133 struct enc_xform enc_xform_3des = {
  134         CRYPTO_3DES_CBC, "3DES",
  135         8, 24, 24,
  136         des3_encrypt,
  137         des3_decrypt,
  138         des3_setkey,
  139         des3_zerokey
  140 };
  141 
  142 struct enc_xform enc_xform_blf = {
  143         CRYPTO_BLF_CBC, "Blowfish",
  144         8, 5, 56 /* 448 bits, max key */,
  145         blf_encrypt,
  146         blf_decrypt,
  147         blf_setkey,
  148         blf_zerokey
  149 };
  150 
  151 struct enc_xform enc_xform_cast5 = {
  152         CRYPTO_CAST_CBC, "CAST-128",
  153         8, 5, 16,
  154         cast5_encrypt,
  155         cast5_decrypt,
  156         cast5_setkey,
  157         cast5_zerokey
  158 };
  159 
  160 struct enc_xform enc_xform_skipjack = {
  161         CRYPTO_SKIPJACK_CBC, "Skipjack",
  162         8, 10, 10,
  163         skipjack_encrypt,
  164         skipjack_decrypt,
  165         skipjack_setkey,
  166         skipjack_zerokey
  167 };
  168 
  169 struct enc_xform enc_xform_rijndael128 = {
  170         CRYPTO_RIJNDAEL128_CBC, "Rijndael-128/AES",
  171         16, 8, 32,
  172         rijndael128_encrypt,
  173         rijndael128_decrypt,
  174         rijndael128_setkey,
  175         rijndael128_zerokey,
  176 };
  177 
  178 struct enc_xform enc_xform_arc4 = {
  179         CRYPTO_ARC4, "ARC4",
  180         1, 1, 32,
  181         NULL,
  182         NULL,
  183         NULL,
  184         NULL,
  185 };
  186 
  187 /* Authentication instances */
  188 struct auth_hash auth_hash_null = {
  189         CRYPTO_NULL_HMAC, "NULL-HMAC",
  190         0, 0, 12, sizeof(int),                  /* NB: context isn't used */
  191         null_init, null_update, null_final
  192 };
  193 
  194 struct auth_hash auth_hash_hmac_md5_96 = {
  195         CRYPTO_MD5_HMAC, "HMAC-MD5",
  196         16, 16, 12, sizeof(MD5_CTX),
  197         (void (*) (void *)) MD5Init, MD5Update_int,
  198         (void (*) (u_int8_t *, void *)) MD5Final
  199 };
  200 
  201 struct auth_hash auth_hash_hmac_sha1_96 = {
  202         CRYPTO_SHA1_HMAC, "HMAC-SHA1",
  203         20, 20, 12, sizeof(SHA1_CTX),
  204         SHA1Init_int, SHA1Update_int, SHA1Final_int
  205 };
  206 
  207 struct auth_hash auth_hash_hmac_ripemd_160_96 = {
  208         CRYPTO_RIPEMD160_HMAC, "HMAC-RIPEMD-160",
  209         20, 20, 12, sizeof(RMD160_CTX),
  210         (void (*)(void *)) RMD160Init, RMD160Update_int,
  211         (void (*)(u_int8_t *, void *)) RMD160Final
  212 };
  213 
  214 struct auth_hash auth_hash_key_md5 = {
  215         CRYPTO_MD5_KPDK, "Keyed MD5", 
  216         0, 16, 12, sizeof(MD5_CTX),
  217         (void (*)(void *)) MD5Init, MD5Update_int,
  218         (void (*)(u_int8_t *, void *)) MD5Final
  219 };
  220 
  221 struct auth_hash auth_hash_key_sha1 = {
  222         CRYPTO_SHA1_KPDK, "Keyed SHA1",
  223         0, 20, 12, sizeof(SHA1_CTX),
  224         SHA1Init_int, SHA1Update_int, SHA1Final_int
  225 };
  226 
  227 struct auth_hash auth_hash_hmac_sha2_256 = {
  228         CRYPTO_SHA2_HMAC, "HMAC-SHA2",
  229         32, 32, 12, sizeof(SHA256_CTX),
  230         (void (*)(void *)) SHA256_Init, SHA256Update_int,
  231         (void (*)(u_int8_t *, void *)) SHA256_Final
  232 };
  233 
  234 struct auth_hash auth_hash_hmac_sha2_384 = {
  235         CRYPTO_SHA2_HMAC, "HMAC-SHA2-384",
  236         48, 48, 12, sizeof(SHA384_CTX),
  237         (void (*)(void *)) SHA384_Init, SHA384Update_int,
  238         (void (*)(u_int8_t *, void *)) SHA384_Final
  239 };
  240 
  241 struct auth_hash auth_hash_hmac_sha2_512 = {
  242         CRYPTO_SHA2_HMAC, "HMAC-SHA2-512",
  243         64, 64, 12, sizeof(SHA512_CTX),
  244         (void (*)(void *)) SHA512_Init, SHA512Update_int,
  245         (void (*)(u_int8_t *, void *)) SHA512_Final
  246 };
  247 
  248 /* Compression instance */
  249 struct comp_algo comp_algo_deflate = {
  250         CRYPTO_DEFLATE_COMP, "Deflate",
  251         90, deflate_compress,
  252         deflate_decompress
  253 };
  254 
  255 /*
  256  * Encryption wrapper routines.
  257  */
  258 static void
  259 null_encrypt(caddr_t key, u_int8_t *blk)
  260 {
  261 }
  262 static void
  263 null_decrypt(caddr_t key, u_int8_t *blk)
  264 {
  265 }
  266 static int
  267 null_setkey(u_int8_t **sched, u_int8_t *key, int len)
  268 {
  269         *sched = NULL;
  270         return 0;
  271 }
  272 static void
  273 null_zerokey(u_int8_t **sched)
  274 {
  275         *sched = NULL;
  276 }
  277 
  278 static void
  279 des1_encrypt(caddr_t key, u_int8_t *blk)
  280 {
  281         des_cblock *cb = (des_cblock *) blk;
  282         des_key_schedule *p = (des_key_schedule *) key;
  283 
  284         des_ecb_encrypt(cb, cb, p[0], DES_ENCRYPT);
  285 }
  286 
  287 static void
  288 des1_decrypt(caddr_t key, u_int8_t *blk)
  289 {
  290         des_cblock *cb = (des_cblock *) blk;
  291         des_key_schedule *p = (des_key_schedule *) key;
  292 
  293         des_ecb_encrypt(cb, cb, p[0], DES_DECRYPT);
  294 }
  295 
  296 static int
  297 des1_setkey(u_int8_t **sched, u_int8_t *key, int len)
  298 {
  299         des_key_schedule *p;
  300         int err;
  301 
  302         MALLOC(p, des_key_schedule *, sizeof (des_key_schedule),
  303                 M_CRYPTO_DATA, M_NOWAIT|M_ZERO);
  304         if (p != NULL) {
  305                 des_set_key((des_cblock *) key, p[0]);
  306                 err = 0;
  307         } else
  308                 err = ENOMEM;
  309         *sched = (u_int8_t *) p;
  310         return err;
  311 }
  312 
  313 static void
  314 des1_zerokey(u_int8_t **sched)
  315 {
  316         bzero(*sched, sizeof (des_key_schedule));
  317         FREE(*sched, M_CRYPTO_DATA);
  318         *sched = NULL;
  319 }
  320 
  321 static void
  322 des3_encrypt(caddr_t key, u_int8_t *blk)
  323 {
  324         des_cblock *cb = (des_cblock *) blk;
  325         des_key_schedule *p = (des_key_schedule *) key;
  326 
  327         des_ecb3_encrypt(cb, cb, p[0], p[1], p[2], DES_ENCRYPT);
  328 }
  329 
  330 static void
  331 des3_decrypt(caddr_t key, u_int8_t *blk)
  332 {
  333         des_cblock *cb = (des_cblock *) blk;
  334         des_key_schedule *p = (des_key_schedule *) key;
  335 
  336         des_ecb3_encrypt(cb, cb, p[0], p[1], p[2], DES_DECRYPT);
  337 }
  338 
  339 static int
  340 des3_setkey(u_int8_t **sched, u_int8_t *key, int len)
  341 {
  342         des_key_schedule *p;
  343         int err;
  344 
  345         MALLOC(p, des_key_schedule *, 3*sizeof (des_key_schedule),
  346                 M_CRYPTO_DATA, M_NOWAIT|M_ZERO);
  347         if (p != NULL) {
  348                 des_set_key((des_cblock *)(key +  0), p[0]);
  349                 des_set_key((des_cblock *)(key +  8), p[1]);
  350                 des_set_key((des_cblock *)(key + 16), p[2]);
  351                 err = 0;
  352         } else
  353                 err = ENOMEM;
  354         *sched = (u_int8_t *) p;
  355         return err;
  356 }
  357 
  358 static void
  359 des3_zerokey(u_int8_t **sched)
  360 {
  361         bzero(*sched, 3*sizeof (des_key_schedule));
  362         FREE(*sched, M_CRYPTO_DATA);
  363         *sched = NULL;
  364 }
  365 
  366 static void
  367 blf_encrypt(caddr_t key, u_int8_t *blk)
  368 {
  369         BF_LONG t[2];
  370 
  371         memcpy(t, blk, sizeof (t));
  372         t[0] = ntohl(t[0]);
  373         t[1] = ntohl(t[1]);
  374         /* NB: BF_encrypt expects the block in host order! */
  375         BF_encrypt(t, (BF_KEY *) key);
  376         t[0] = htonl(t[0]);
  377         t[1] = htonl(t[1]);
  378         memcpy(blk, t, sizeof (t));
  379 }
  380 
  381 static void
  382 blf_decrypt(caddr_t key, u_int8_t *blk)
  383 {
  384         BF_LONG t[2];
  385 
  386         memcpy(t, blk, sizeof (t));
  387         t[0] = ntohl(t[0]);
  388         t[1] = ntohl(t[1]);
  389         /* NB: BF_decrypt expects the block in host order! */
  390         BF_decrypt(t, (BF_KEY *) key);
  391         t[0] = htonl(t[0]);
  392         t[1] = htonl(t[1]);
  393         memcpy(blk, t, sizeof (t));
  394 }
  395 
  396 static int
  397 blf_setkey(u_int8_t **sched, u_int8_t *key, int len)
  398 {
  399         int err;
  400 
  401         MALLOC(*sched, u_int8_t *, sizeof(BF_KEY),
  402                 M_CRYPTO_DATA, M_NOWAIT|M_ZERO);
  403         if (*sched != NULL) {
  404                 BF_set_key((BF_KEY *) *sched, len, key);
  405                 err = 0;
  406         } else
  407                 err = ENOMEM;
  408         return err;
  409 }
  410 
  411 static void
  412 blf_zerokey(u_int8_t **sched)
  413 {
  414         bzero(*sched, sizeof(BF_KEY));
  415         FREE(*sched, M_CRYPTO_DATA);
  416         *sched = NULL;
  417 }
  418 
  419 static void
  420 cast5_encrypt(caddr_t key, u_int8_t *blk)
  421 {
  422         cast_encrypt((cast_key *) key, blk, blk);
  423 }
  424 
  425 static void
  426 cast5_decrypt(caddr_t key, u_int8_t *blk)
  427 {
  428         cast_decrypt((cast_key *) key, blk, blk);
  429 }
  430 
  431 static int
  432 cast5_setkey(u_int8_t **sched, u_int8_t *key, int len)
  433 {
  434         int err;
  435 
  436         MALLOC(*sched, u_int8_t *, sizeof(cast_key), M_CRYPTO_DATA, M_NOWAIT|M_ZERO);
  437         if (*sched != NULL) {
  438                 cast_setkey((cast_key *)*sched, key, len);
  439                 err = 0;
  440         } else
  441                 err = ENOMEM;
  442         return err;
  443 }
  444 
  445 static void
  446 cast5_zerokey(u_int8_t **sched)
  447 {
  448         bzero(*sched, sizeof(cast_key));
  449         FREE(*sched, M_CRYPTO_DATA);
  450         *sched = NULL;
  451 }
  452 
  453 static void
  454 skipjack_encrypt(caddr_t key, u_int8_t *blk)
  455 {
  456         skipjack_forwards(blk, blk, (u_int8_t **) key);
  457 }
  458 
  459 static void
  460 skipjack_decrypt(caddr_t key, u_int8_t *blk)
  461 {
  462         skipjack_backwards(blk, blk, (u_int8_t **) key);
  463 }
  464 
  465 static int
  466 skipjack_setkey(u_int8_t **sched, u_int8_t *key, int len)
  467 {
  468         int err;
  469 
  470         /* NB: allocate all the memory that's needed at once */
  471         MALLOC(*sched, u_int8_t *, 10 * (sizeof(u_int8_t *) + 0x100),
  472                 M_CRYPTO_DATA, M_NOWAIT|M_ZERO);
  473         if (*sched != NULL) {
  474                 u_int8_t** key_tables = (u_int8_t**) *sched;
  475                 u_int8_t* table = (u_int8_t*) &key_tables[10];
  476                 int k;
  477 
  478                 for (k = 0; k < 10; k++) {
  479                         key_tables[k] = table;
  480                         table += 0x100;
  481                 }
  482                 subkey_table_gen(key, (u_int8_t **) *sched);
  483                 err = 0;
  484         } else
  485                 err = ENOMEM;
  486         return err;
  487 }
  488 
  489 static void
  490 skipjack_zerokey(u_int8_t **sched)
  491 {
  492         bzero(*sched, 10 * (sizeof(u_int8_t *) + 0x100));
  493         FREE(*sched, M_CRYPTO_DATA);
  494         *sched = NULL;
  495 }
  496 
  497 static void
  498 rijndael128_encrypt(caddr_t key, u_int8_t *blk)
  499 {
  500         rijndael_encrypt((rijndael_ctx *) key, (u_char *) blk, (u_char *) blk);
  501 }
  502 
  503 static void
  504 rijndael128_decrypt(caddr_t key, u_int8_t *blk)
  505 {
  506         rijndael_decrypt(((rijndael_ctx *) key) + 1, (u_char *) blk,
  507             (u_char *) blk);
  508 }
  509 
  510 static int
  511 rijndael128_setkey(u_int8_t **sched, u_int8_t *key, int len)
  512 {
  513         int err;
  514 
  515         MALLOC(*sched, u_int8_t *, 2 * sizeof(rijndael_ctx), M_CRYPTO_DATA,
  516             M_NOWAIT|M_ZERO);
  517         if (*sched != NULL) {
  518                 rijndael_set_key((rijndael_ctx *) *sched, (u_char *) key, len * 8, 1);
  519                 rijndael_set_key(((rijndael_ctx *) *sched) + 1, (u_char *) key,
  520                     len * 8, 0);
  521                 err = 0;
  522         } else
  523                 err = ENOMEM;
  524         return err;
  525 }
  526 
  527 static void
  528 rijndael128_zerokey(u_int8_t **sched)
  529 {
  530         bzero(*sched, 2 * sizeof(rijndael_ctx));
  531         FREE(*sched, M_CRYPTO_DATA);
  532         *sched = NULL;
  533 }
  534 
  535 /*
  536  * And now for auth.
  537  */
  538 
  539 static void
  540 null_init(void *ctx)
  541 {
  542 }
  543 
  544 static int
  545 null_update(void *ctx, u_int8_t *buf, u_int16_t len)
  546 {
  547         return 0;
  548 }
  549 
  550 static void
  551 null_final(u_int8_t *buf, void *ctx)
  552 {
  553         if (buf != (u_int8_t *) 0)
  554                 bzero(buf, 12);
  555 }
  556 
  557 static int
  558 RMD160Update_int(void *ctx, u_int8_t *buf, u_int16_t len)
  559 {
  560         RMD160Update(ctx, buf, len);
  561         return 0;
  562 }
  563 
  564 static int
  565 MD5Update_int(void *ctx, u_int8_t *buf, u_int16_t len)
  566 {
  567         MD5Update(ctx, buf, len);
  568         return 0;
  569 }
  570 
  571 static void
  572 SHA1Init_int(void *ctx)
  573 {
  574         SHA1Init(ctx);
  575 }
  576 
  577 static int
  578 SHA1Update_int(void *ctx, u_int8_t *buf, u_int16_t len)
  579 {
  580         SHA1Update(ctx, buf, len);
  581         return 0;
  582 }
  583 
  584 static void
  585 SHA1Final_int(u_int8_t *blk, void *ctx)
  586 {
  587         SHA1Final(blk, ctx);
  588 }
  589 
  590 static int
  591 SHA256Update_int(void *ctx, u_int8_t *buf, u_int16_t len)
  592 {
  593         SHA256_Update(ctx, buf, len);
  594         return 0;
  595 }
  596 
  597 static int
  598 SHA384Update_int(void *ctx, u_int8_t *buf, u_int16_t len)
  599 {
  600         SHA384_Update(ctx, buf, len);
  601         return 0;
  602 }
  603 
  604 static int
  605 SHA512Update_int(void *ctx, u_int8_t *buf, u_int16_t len)
  606 {
  607         SHA512_Update(ctx, buf, len);
  608         return 0;
  609 }
  610 
  611 /*
  612  * And compression
  613  */
  614 
  615 static u_int32_t
  616 deflate_compress(data, size, out)
  617         u_int8_t *data;
  618         u_int32_t size;
  619         u_int8_t **out;
  620 {
  621         return deflate_global(data, size, 0, out);
  622 }
  623 
  624 static u_int32_t
  625 deflate_decompress(data, size, out)
  626         u_int8_t *data;
  627         u_int32_t size;
  628         u_int8_t **out;
  629 {
  630         return deflate_global(data, size, 1, out);
  631 }

Cache object: 285bc64f2bacfaa6cb373c59311b9e70


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.