예제 #1
0
파일: sha256.c 프로젝트: maxsaritasa/m1docs
int wc_InitSha256(Sha256* sha256)
{
    int ret = 0;
    #ifdef FREESCALE_MMCAU
        ret = wolfSSL_CryptHwMutexLock();
        if(ret != 0) {
            return ret;
        }
        cau_sha256_initialize_output(sha256->digest);
        wolfSSL_CryptHwMutexUnLock();
    #else
        sha256->digest[0] = 0x6A09E667L;
        sha256->digest[1] = 0xBB67AE85L;
        sha256->digest[2] = 0x3C6EF372L;
        sha256->digest[3] = 0xA54FF53AL;
        sha256->digest[4] = 0x510E527FL;
        sha256->digest[5] = 0x9B05688CL;
        sha256->digest[6] = 0x1F83D9ABL;
        sha256->digest[7] = 0x5BE0CD19L;
    #endif

    sha256->buffLen = 0;
    sha256->loLen   = 0;
    sha256->hiLen   = 0;
    
    return ret;
}
예제 #2
0
파일: sha256.c 프로젝트: BrianAker/cyassl
void InitSha256(Sha256* sha256)
{
    #ifdef FREESCALE_MMCAU
        cau_sha256_initialize_output(sha256->digest);
    #else
        sha256->digest[0] = 0x6A09E667L;
        sha256->digest[1] = 0xBB67AE85L;
        sha256->digest[2] = 0x3C6EF372L;
        sha256->digest[3] = 0xA54FF53AL;
        sha256->digest[4] = 0x510E527FL;
        sha256->digest[5] = 0x9B05688CL;
        sha256->digest[6] = 0x1F83D9ABL;
        sha256->digest[7] = 0x5BE0CD19L;
    #endif

    sha256->buffLen = 0;
    sha256->loLen   = 0;
    sha256->hiLen   = 0;
}
예제 #3
0
/* cau_sha256_initialize_output(). not this function has different return value (int) that the other two (void) */
status_t MMCAU_SHA256_InitializeOutput(uint32_t *sha256State)
{
    status_t status;
    int ret;

    if (sha256State)
    {
        uint8_t hashStateAlign[MMCAU_HASH_STATE_SIZE];
        void *hashStateWork;
        bool copyInOut;
        /* align pointer */
        hashStateWork = mmcau_align(sha256State, hashStateAlign, &copyInOut);
        if (copyInOut)
        {
            mmcau_memcpy(hashStateAlign, sha256State, MMCAU_SHA256_STATE_SIZE);
        }
        /* CAU API */
        ret = cau_sha256_initialize_output(hashStateWork);
        /* copy result to unaligned pointer */
        if (copyInOut)
        {
            mmcau_memcpy(sha256State, hashStateAlign, MMCAU_SHA256_STATE_SIZE);
        }
        if (ret == 0)
        {
            status = kStatus_Success;
        }
        else
        {
            status = kStatus_Fail;
        }
    }
    else
    {
        status = kStatus_InvalidArgument;
    }
    return status;
}