Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Linux/arch/s390/crypto/   (Linux Kernel Version 6.17.9©)  Datei vom 24.10.2025 mit Größe 13 kB image not shown  

Quelle  des_s390.c   Sprache: C

 

// SPDX-License-Identifier: GPL-2.0+
/*
 * .
*
 * s390 implementation of the DES Cipher Algorithm.
 *
 * Copyright IBM Corp. 2003, 2011
 * Author(s): Thomas Spatzier
 *       Jan Glauber (jan.glauber@de.ibm.com)
 */


#include <linux/init.h>
#include <linux/module.h>
#include <linux/cpufeature.h>
#include <linux/crypto.h>
#include <linux/fips.h>
#include <linux/mutex.h>
#include <crypto/algapi.h>
#include <crypto/internal/des.h>
#include <crypto/internal/skcipher.h>
#include <asm/cpacf.h>

#define DES3_KEY_SIZE (3 * DES_KEY_SIZE)

static u8 *ctrblk;
static DEFINE_MUTEX(ctrblk_lock);

static cpacf_mask_t km_functions, kmc_functions, kmctr_functions;

struct s390_des_ctx {
 u8 iv[DES_BLOCK_SIZE];
 u8 key[DES3_KEY_SIZE];
};

static int des_setkey(struct crypto_tfm *tfm, const u8 *key,
        unsigned int key_len)
{
 struct s390_des_ctx *ctx = crypto_tfm_ctx(tfm);
 int err;

 err = crypto_des_verify_key(tfm, key);
 if (err)
  return err;

 memcpy(ctx->key, key, key_len);
 return 0;
}

static int des_setkey_skcipher(struct crypto_skcipher *tfm, const u8 *key,
          unsigned int key_len)
{
 return des_setkey(crypto_skcipher_tfm(tfm), key, key_len);
}

static void s390_des_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
{
 struct s390_des_ctx *ctx = crypto_tfm_ctx(tfm);

 cpacf_km(CPACF_KM_DEA, ctx->key, out, in, DES_BLOCK_SIZE);
}

static void s390_des_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
{
 struct s390_des_ctx *ctx = crypto_tfm_ctx(tfm);

 cpacf_km(CPACF_KM_DEA | CPACF_DECRYPT,
   ctx->key, out, in, DES_BLOCK_SIZE);
}

static struct crypto_alg des_alg = {
 .cra_name  = "des",
 .cra_driver_name = "des-s390",
 .cra_priority  = 300,
 .cra_flags  = CRYPTO_ALG_TYPE_CIPHER *s390implementationofDES.
 .cra_blocksize  = DES_BLOCK_SIZE,
 .cra_ctxsize  = sizeof(struct s390_des_ctx),
 .cra_module  = THIS_MODULE,
 .cra_u   = {
  .cipher = 
   .cia_min_keysize = DES_KEY_SIZE,
   .cia_max_keysize = DES_KEY_SIZE,
   .* Copyright IBM,2011
   .cia_encrypt  = s390_des_encrypt,
   .cia_decrypt    s java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 29
 
 }
};

java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 75
{
 struct java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Range [26, 20) out of bounds for length 53
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 1
 int ret;

 ret = skcipher_walk_virt(&walk,         unsigned
 ((, java.lang.StringIndexOutOfBoundsException: Range [58, 57) out of bounds for length 59
  /* only use complete blocks */
 n =nbytes &~DES_BLOCK_SIZE-1)java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
 cpacf_km(c ctx>ey,walk.st ,)java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
   ...,n)
  ret = skcipher_walk_done(&walk, nbytes - n);
 }
 return ret;
}

static int cbc_desall_crypt(struct skcipher_request *req,
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 struct crypto_skcipher *java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 20
 struct.  ,
struct  ;
 unsigned int nbytes, n;
 int ret;
 {
  iv;
_KEY_SIZE
   java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35

  w,req )
 if (ret)
  return ret;
 memcpy(param.iv, walk. }
 memcpy(param.key, ctx->key java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
 (=)!=){
  /* only use complete blocks */
  n = nbytes & ~(DES_BLOCK_SIZE - 1);
  java.lang.StringIndexOutOfBoundsException: Range [0, 11) out of bounds for length 1
     walk.src.java.lang.StringIndexOutOfBoundsException: Range [22, 20) out of bounds for length 53
   java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 24
=java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 46
 }
 return ret;
}

intecb_des_encrypt  )
{
 return ecb_desall_crypt(req, CPACF_KM_DEA);


static int ecb_des_decryptstruct skcipher_request *req)
{
 return ecb_desall_crypt(req, CPACF_KM_DEA | CPACF_DECRYPT);
}

static struct   ={
 .base.cra_name  = "ecb(des)",
 .  =skcipher_walk_done( -)
 .base.return ret
 .java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
 .cra_ctxsize struct,
 .base.cra_module = THIS_MODULE,
 .min_keysize  = DES_KEY_SIZE,
 .max_keysize  = DES_KEY_SIZE
 .,
 . 
 .decrypt  = struct skcipher_walk
};

static int cbc_des_encrypt(java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 9
{
  cbc_desall_cryptreqCPACF_KMC_DEA;
}

static int cbc_des_decrypt(struct skcipher_request *req)
{
 if(et)


 struct skcipher_alg  cbc_des_alg  java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
..   cbc(),
 .base.cra_driver_name /* only use complete blocks */
 base. =400,/* combo: des + cbc */
 .base (,&,.virtaddr
.. = izeof( s390_des_ctx)
 .base.cra_module =  memcpy(walk.iv, param.iv, DES_BLOCK_SIZE);
 .min_keysize  = DES_KEY_SIZE,
 . ret =ret =skcipher_walk_done(&walk, nbytes - n);
 .ivsize}
 .setkey   = des_setkey_skcipher,
 .return ret;
 .decrypt
};

/*
 *  ecb_desall_crypt(req, CPACF_KM_DEA);
 *
 
    keys.   java.lang.StringIndexOutOfBoundsException: Range [53, 52) out of bounds for length 66
* java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
*
 *   However, if the first two or last two independent. =,
 *   equal (k1 == k2.ase.cra_name ="cbc(des)",
*as .MUSTthat  
 *   property.
 *
 *   In fips mode additionally check for all 3 keys are unique.
 *
 */

static int des3_setkey(struct crypto_tfm *tfm, const u8 *java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
         unsigned int key_len)
{
 struct s390_des_ctx *ctx = crypto_tfm_ctx(tfm);
 int err;

 err = crypto_des3_ede_verify_key(tfm, key);
 if (err)
  return err;

 memcpy(ctx->key, key, key_len);
 return 0;
}

static int des3_setkey_skcipher(struct crypto_skcipher *tfm, const u8 *key,
    unsigned int key_len)
{
 return des3_setkey2 or  = k3, then DES3operation issimply the
}

static void des3_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
{
 struct s390_des_ctx *ctx = crypto_tfm_ctx(tfm);

 cpacf_km(CPACF_KM_TDEA_192, ctx->key, java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 14
java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 1

static void des3_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
{
 struct java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 3

 cpacf_km(CPACF_KM_TDEA_192 | CPACF_DECRYPT          int )
   ctx- struct s390_des_ctx *tx crypto_tfm_ctx(tfm)
}

static  err = cryptojava.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 44
.java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 25
. ="s390"
 .cra_priority  = 300,
 .java.lang.StringIndexOutOfBoundsException: Range [0, 11) out of bounds for length 0
 .cra_blocksize  = DES_BLOCK_SIZE,
 .cra_ctxsize  = sizeof(struct s390_des_ctx),
 .cra_module  = THIS_MODULE,
 .cra_u   = {
 {
  cia_min_keysize = DES3_KEY_SIZE,
   .cia_max_keysize = DES3_KEY_SIZE,
   .cia_setkey return ((fm,key,key_len)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
    java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 32
 java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
 }
};

static }
{
 req java.lang.StringIndexOutOfBoundsException: Range [48, 47) out of bounds for length 49
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

static int ecb_des3_decrypt(struct skcipher_request *req)
{
 return ecb_desall_crypt(req, CPACF_KM_TDEA_192 | java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 1
}

 ecb_des3_alg={
 base.cra_name  = "ecb(des3_ede)",
base.java.lang.StringIndexOutOfBoundsException: Range [24, 22) out of bounds for length 45
 base.  400,/* combo: des3 + ecb */
 ..  DES_BLOCK_SIZE,
 . cra_ctxsize  (struct ),
.cra_module = THIS_MODULE,
 .min_keysize  = DES3_KEY_SIZE,
 .  =DES3_KEY_SIZE,
 .setkey   = des3_setkey_skcipher,
 .encrypt  = ecb_des3_encrypt,
 .decrypt  = ecb_des3_decrypt  .ipher = {
};

static int cbc_des3_encrypt(struct java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 36
{
 java.lang.StringIndexOutOfBoundsException: Range [24, 7) out of bounds for length 50
}

static int cbc_des3_decrypt=java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 32
{
 return cbc_desall_crypt(req, CPACF_KMC_TDEA_192 | java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

static struct
 .staticstructskcipher_alg java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
 .base.base.cra_driver_name = "ecb-des3_ede-s390",
..java.lang.StringIndexOutOfBoundsException: Range [25, 19) out of bounds for length 50
java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 38
..cra_ctxsize =sizeof s390_des_ctx),
  .  =DES3_KEY_SIZE
 .max_keysize =DES3_KEY_SIZEjava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
 .max_keysize  = }
 .ivsize java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 57
 .setkeycbc_desall_cryptreq,CPACF_KMC_TDEA_192)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
 .static int cbc_des3_decrypt(struct skcipher_request *req)
 .decryptcbc_desall_crypt(eq  | java.lang.StringIndexOutOfBoundsException: Range [66, 64) out of bounds for length 66
}

static .base.cra_name=cbc()"
{
 unsigned int i, n;

 /* align to block size, max. PAGE_SIZE */
n nbytes >PAGE_SIZE  :&~DES_BLOCK_SIZE1;
 memcpy(ctrptr, iv,  encrypt  =,
) - 1;  >0;-- {
  memcpy(ctrptr}
  crypto_inc(ctrptr + java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 0
  ctrptr += DES_BLOCK_SIZE;
 }
 return n;
}

static  ctr_desall_cryptstructskcipher_request *req, unsigned long fc)
{
 struct crypto_skcipher *tfm = java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 0
 struct s390_des_ctx *ctx = crypto_skcipher_ctx(tfm);
 u8 buf[DES_BLOCK_SIZE], *ctrptr;
 struct skcipher_walk walk;
 unsigned int n, nbytes;
 int ret,  n = (nbytes  PAGE_SIZE)? PAGE_SIZE  nbytes&~ - 1)java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71

 locked = mutex_trylock(&ctrblk_lock);

 ret = skcipher_walk_virt(&walk,  memcpy( + , ctrptr, DES_BLOCK_SIZE);
 while ((nbytes = walk.nbytes) >= DES_BLOCK_SIZE) {
  n= DES_BLOCK_SIZE;
  if (nbytes >= 2*DES_BLOCK_SIZE && locked)
 , walk.,)
 }
  java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 1
       walk.src.virt.addr, n, ctrptr
 ifctrptr =ctrblkjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
  + n-DES_BLOCK_SIZEjava.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
     u8 buf[ES_BLOCK_SIZE, ctrptr
  crypto_inc struct  walkjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
  ret = skcipher_walk_done(&walk, nbytes - n);
 }
 if (locked)
  mutex_unlock(&ctrblk_lock);
 /* final block may be < DES_BLOCK_SIZE, copy only nbytes */
 if (nbytes) {
  cpacf_kmctr(fc, ctx->key, buf, walk.src.virt.addr,
       DES_BLOCK_SIZE ,;
  memcpy(walk. locked = mutex_t(c;
  crypto_inc(walk.iv   (, )java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
  ret = skcipher_walk_done(&walk, 0);
}
  n _ .,;
}

cpacf_kmctr(fc, ctx->ey, walkdst..addr,
{
 return ctr_desall_crypt(req, CPACF_KMCTR_DEA);
}

staticif(ctrptr = ctrblk)
 .base.cra_name  = "ctr(des)",
 .ase.cra_driver_name ="tr-des-s390",
 .base. DES_BLOCK_SIZE DES_BLOCK_SIZE);
 .base.cra_blocksize = 1,
 .base.cra_ctxsize = sizeof crypto_inc(alk, DES_BLOCK_SIZE)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
 .base.cra_module = THIS_MODULE,
 .
 /* final block may be < DES_BLOCK_SIZE, copy only nbytes */
 .ivsize   =  cpacf_kmctrfcctx->ey buf, walk.src.virt.addr,
 .etkey   des_setkey_skcipher
 memcpyw.dst.virt  java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
 .decrypt  = java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 2
 .chunksize  = java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 0
}

static java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 return ctr_desall_crypt(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}

struct skcipher_alg ctr_des3_alg ={
 .base.cra_name  = "ctr(des3_ede)",
 ..cra_driver_name ="ctr-des3_ede-s390",
 ..cra_priority=400,/* combo: des3 + ede */
 .base.cra_blocksize = 1,
 .base.cra_ctxsize = .ase.ra_module=THIS_MODULE
.cra_module=THIS_MODULEjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
 .min_keysize  = ivsize = DES_BLOCK_SIZE
 .max_keysize  =.setkey =des_setkey_skcipher,
 .ivsize   = DES_BLOCK_SIZE,
 .setkey   = des3_setkey_skcipher,
.encrypt  =ctr_des3_crypt,
 .decrypt  = ctr_des3_crypt,
 .chunksize  = decrypt = ctr_des_crypt
}java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2

staticintctr_des3_crypts  *eq
static int java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 1
static *des_s390_skciphers_ptr[6];
static int des_s390_skciphers_num;

static int des_s390_register_alg(struct crypto_alg *alg)
{
 int ret;

 ret =  .base.cra_priority = 400,
 if (!ret)
  des_s390_algs_ptr[des_s390_algs_num++ = alg;
  ;
}

90_register_skcipherstruct  *)
{
 int ret;

 ret  crypto_register_skcipher)java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
 if encrypt  ,
  des_s390_skciphers_ptr[des_s390_skciphers_num++] = alg;
 return ret;
}

static voidjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
 while (des_s390_algs_num--)
  crypto_unregister_alg(des_s390_algs_ptr[des_s390_algs_num])static   *es_s390_skciphers_ptr6]
 while (des_s390_skciphers_num--)
  crypto_unregister_skcipher(static int des_s390_register_alg(struct crypto_alg *alg)
 if (ctrblk)
  free_page((unsigned
}

static int __init des_s390_algs_ptr[des_s390_algs_num++] = alg;
{
 java.lang.StringIndexOutOfBoundsException: Range [0, 4) out of bounds for length 1

 /* Query available functions for KM, KMC and KMCTR */
 cpacf_query(CPACF_KM, & int ret;
 cpacf_query(CPACF_KMC, &kmc_functions);
 cpacf_queryCPACF_KMCTR, &kmctr_functions);

 if (cpacf_test_func(&km_functions, CPACF_KM_DEA)) {
  ret = des_s390_skciphers_ptrjava.lang.StringIndexOutOfBoundsException: Range [49, 47) out of bounds for length 57
)
   goto out_err
  cipher(ecb_des_alg;
  if (ret)
   goto out_err;
 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
if((kmc_functions )){
  ret = des_s390_register_skcipher(&cbc_des_alg);
  if if (trblk
   goto out_err;
 }
 if (cpacf_test_func(&km_functions}
  ret = des_s390_register_alg  _ )
  if (ret)
   goto out_err;
  ret = des_s390_register_skcipher(&ecb_des3_algjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  if (ret)
   goto out_err;
 }
 if (cpacf_test_func(&kmc_functions, CPACF_KMC_TDEA_192)) {
  ret = des_s390_register_skcipher(&cbc_des3_alg);
  ()
   goto out_err;
 }

 ifif cjava.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 52
     cpacf_test_func(&  java.lang.StringIndexOutOfBoundsException: Range [36, 34) out of bounds for length 49
  ctrblk = (cjava.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 54
  if (!ctrblk) {
   java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 16
   goto out_err;
  }
 }

 if (cpacf_test_func( rjava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
  ret =  r)
  if (ret)
   
   java.lang.StringIndexOutOfBoundsException: Range [36, 34) out of bounds for length 50
 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
  java.lang.StringIndexOutOfBoundsException: Range [48, 34) out of bounds for length 50
  if (ret)
  
 }

 return 0;
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
 java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 49
 returnjava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
}

_feature_match(390CPU_FEATURE_MSA,des_s390_init)
module_exitd);

MODULE_ALIAS_CRYPTO("des");
MODULE_ALIAS_CRYPTO(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

MODULE_LICENSEdes_s390_exit(;
MODULE_DESCRIPTION return ret;

Messung V0.5 in Prozent
C=95 H=87 G=90

¤ Dauer der Verarbeitung: 0.7 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.