Esempio n. 1
0
/*
*  USHAInput
*
*  Description:
*      This function accepts an array of octets as the next portion
*      of the message.
*
*  Parameters:
*      context: [in/out]
*          The SHA context to update
*      message_array: [in]
*          An array of characters representing the next portion of
*          the message.
*      length: [in]
*          The length of the message in message_array
*
*  Returns:
*      sha Error Code.
*
*/
int USHAInput(USHAContext *ctx,
    const uint8_t *bytes, unsigned int bytecount)
{
    if (ctx) {
        switch (ctx->whichSha) {
        case SHA1:
            return SHA1Input((SHA1Context*)&ctx->ctx, bytes, bytecount);
        case SHA224:
            return SHA224Input((SHA224Context*)&ctx->ctx, bytes,
                bytecount);
        case SHA256:
            return SHA256Input((SHA256Context*)&ctx->ctx, bytes,
                bytecount);
        case SHA384:
            return SHA384Input((SHA384Context*)&ctx->ctx, bytes,
                bytecount);
        case SHA512:
            return SHA512Input((SHA512Context*)&ctx->ctx, bytes,
                bytecount);
        default: return shaBadParam;
        }
    }
    else {
        return shaNull;
    }
}
Esempio n. 2
0
/*!
    Adds the first \a length chars of \a data to the cryptographic
    hash.
*/
void QCryptographicHash::addData(const char *data, int length)
{
    switch (d->method) {
    case Sha1:
        sha1Update(&d->sha1Context, (const unsigned char *)data, length);
        break;
#ifdef QT_CRYPTOGRAPHICHASH_ONLY_SHA1
    default:
        Q_ASSERT_X(false, "QCryptographicHash", "Method not compiled in");
        Q_UNREACHABLE();
        break;
#else
    case Md4:
        md4_update(&d->md4Context, (const unsigned char *)data, length);
        break;
    case Md5:
        MD5Update(&d->md5Context, (const unsigned char *)data, length);
        break;
    case Sha224:
        SHA224Input(&d->sha224Context, reinterpret_cast<const unsigned char *>(data), length);
        break;
    case Sha256:
        SHA256Input(&d->sha256Context, reinterpret_cast<const unsigned char *>(data), length);
        break;
    case Sha384:
        SHA384Input(&d->sha384Context, reinterpret_cast<const unsigned char *>(data), length);
        break;
    case Sha512:
        SHA512Input(&d->sha512Context, reinterpret_cast<const unsigned char *>(data), length);
        break;
    case RealSha3_224:
    case Keccak_224:
        sha3Update(&d->sha3Context, reinterpret_cast<const BitSequence *>(data), length*8);
        break;
    case RealSha3_256:
    case Keccak_256:
        sha3Update(&d->sha3Context, reinterpret_cast<const BitSequence *>(data), length*8);
        break;
    case RealSha3_384:
    case Keccak_384:
        sha3Update(&d->sha3Context, reinterpret_cast<const BitSequence *>(data), length*8);
        break;
    case RealSha3_512:
    case Keccak_512:
        sha3Update(&d->sha3Context, reinterpret_cast<const BitSequence *>(data), length*8);
        break;
#endif
    }
    d->result.clear();
}
Esempio n. 3
0
File: low.c Progetto: ucodev/libpsec
int sha384_low_update(SHA384Context *context, const unsigned char *in, size_t in_len) {
	return SHA384Input(context, (uint8_t *) in, in_len);
}