Print this page
9697 Add digest tests to crypto test framework

Split Close
Expand all
Collapse all
          --- old/usr/src/test/crypto-tests/tests/common/cryptotest_pkcs.c
          +++ new/usr/src/test/crypto-tests/tests/common/cryptotest_pkcs.c
↓ open down ↓ 391 lines elided ↑ open up ↑
 392  392  int
 393  393  decrypt_final(crypto_op_t *op, size_t encrlen)
 394  394  {
 395  395          CK_RV rv;
 396  396          CK_ULONG outlen = op->outlen - encrlen;
 397  397          rv = C_DecryptFinal(op->hsession, op->out + encrlen, &outlen);
 398  398          if (rv != CKR_OK)
 399  399                  cryptotest_error("C_DecryptFinal", rv);
 400  400          return (rv);
 401  401  }
      402 +
      403 +/*
      404 + * DIGEST_ functions
      405 + */
      406 +int
      407 +digest_init(crypto_op_t *op)
      408 +{
      409 +        CK_MECHANISM mech;
      410 +        CK_RV rv;
      411 +
      412 +        mech.mechanism = op->mech;
      413 +        mech.pParameter = op->param;
      414 +        mech.ulParameterLen = op->paramlen;
      415 +
      416 +        rv = C_DigestInit(op->hsession, &mech);
      417 +        if (rv != CKR_OK)
      418 +                cryptotest_error("C_DigestInit", rv);
      419 +        return (rv);
      420 +}
      421 +
      422 +int
      423 +digest_single(crypto_op_t *op)
      424 +{
      425 +        CK_RV rv;
      426 +
      427 +        rv = C_Digest(op->hsession, op->in, op->inlen,
      428 +            op->out, (CK_ULONG_PTR)&op->outlen);
      429 +        if (rv != CKR_OK)
      430 +                cryptotest_error("C_Digest", rv);
      431 +        return (rv);
      432 +}
      433 +
      434 +int
      435 +digest_update(crypto_op_t *op, int offset)
      436 +{
      437 +        CK_RV rv;
      438 +
      439 +        rv = C_DigestUpdate(op->hsession, op->in + offset, op->updatelen);
      440 +        if (rv != CKR_OK)
      441 +                cryptotest_error("C_DigestUpdate", rv);
      442 +        return (rv);
      443 +}
      444 +
      445 +int
      446 +digest_final(crypto_op_t *op)
      447 +{
      448 +        CK_RV rv;
      449 +
      450 +        rv = C_DigestFinal(op->hsession, op->out, (CK_ULONG_PTR)&op->outlen);
      451 +        if (rv != CKR_OK)
      452 +                cryptotest_error("C_DigestFinal", rv);
      453 +        return (rv);
      454 +}
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX