Ejemplo n.º 1
0
/*
 *  USHAReset
 *
 *  Description:
 *      This function will initialize the SHA Context in preparation
 *      for computing a new SHA message digest.
 *
 *  Parameters:
 *      context: [in/out]
 *          The context to reset.
 *      whichSha: [in]
 *          Selects which SHA reset to call
 *
 *  Returns:
 *      sha Error Code.
 *
 */
int USHAReset(USHAContext *context, enum SHAversion whichSha)
{
  if (!context) return shaNull;
  context->whichSha = whichSha;
  switch (whichSha) {
    case SHA1:   return SHA1Reset((SHA1Context*)&context->ctx);
    case SHA224: return SHA224Reset((SHA224Context*)&context->ctx);
    case SHA256: return SHA256Reset((SHA256Context*)&context->ctx);
    case SHA384: return SHA384Reset((SHA384Context*)&context->ctx);
    case SHA512: return SHA512Reset((SHA512Context*)&context->ctx);
    default: return shaBadParam;
  }
}
Ejemplo n.º 2
0
void md_map_sh512(uint8_t *hash, const uint8_t *msg, int len) {
	SHA512Context ctx;

	if (SHA512Reset(&ctx) != shaSuccess) {
		THROW(ERR_NO_VALID);
	}
	if (SHA512Input(&ctx, msg, len) != shaSuccess) {
		THROW(ERR_NO_VALID);
	}
	if (SHA512Result(&ctx, hash) != shaSuccess) {
		THROW(ERR_NO_VALID);
	}
}
Ejemplo n.º 3
0
/*!
  Resets the object.
*/
void QCryptographicHash::reset()
{
    switch (d->method) {
    case Sha1:
        sha1InitState(&d->sha1Context);
        break;
#ifdef QT_CRYPTOGRAPHICHASH_ONLY_SHA1
    default:
        Q_ASSERT_X(false, "QCryptographicHash", "Method not compiled in");
        Q_UNREACHABLE();
        break;
#else
    case Md4:
        md4_init(&d->md4Context);
        break;
    case Md5:
        MD5Init(&d->md5Context);
        break;
    case Sha224:
        SHA224Reset(&d->sha224Context);
        break;
    case Sha256:
        SHA256Reset(&d->sha256Context);
        break;
    case Sha384:
        SHA384Reset(&d->sha384Context);
        break;
    case Sha512:
        SHA512Reset(&d->sha512Context);
        break;
    case RealSha3_224:
    case Keccak_224:
        sha3Init(&d->sha3Context, 224);
        break;
    case RealSha3_256:
    case Keccak_256:
        sha3Init(&d->sha3Context, 256);
        break;
    case RealSha3_384:
    case Keccak_384:
        sha3Init(&d->sha3Context, 384);
        break;
    case RealSha3_512:
    case Keccak_512:
        sha3Init(&d->sha3Context, 512);
        break;
#endif
    }
    d->result.clear();
}
Ejemplo n.º 4
0
Archivo: low.c Proyecto: ucodev/libpsec
/* SHA512 Low Level Interface */
int sha512_low_init(SHA512Context *context) {
	return SHA512Reset(context);
}