md2-alt.cpp revision 4e91d2cbc15d5c99dff9f027ad68628aeacf4498
/* $Id$ */
/** @file
* IPRT - Message-Digest Algorithm 2, Alternative Implementation.
*/
/*
* Copyright (C) 2009-2014 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Defined Constants And Macros *
*******************************************************************************/
/** The MD2 block size. */
#define RTMD2_BLOCK_SIZE 16
/** The offset of the buffer into RTMD2ALTPRIVATECTX::abStateX. */
#define RTMD2_BUF_OFF RTMD2_BLOCK_SIZE
/*******************************************************************************
* Header Files *
*******************************************************************************/
/** Our private context structure. */
typedef struct RTMD2ALTPRIVATECTX
{
/** The state (X).
* The staging buffer starts byte 16. */
/** The checksum. */
/** The number of buffered bytes. */
#define RT_MD2_PRIVATE_ALT_CONTEXT
/*******************************************************************************
* Global Variables *
*******************************************************************************/
/** PI substitation used by MD2. */
{
41, 46, 67, 201, 162, 216, 124, 1, 61, 54, 84, 161, 236, 240, 6, 19,
98, 167, 5, 243, 192, 199, 115, 140, 152, 147, 43, 217, 188, 76, 130, 202,
30, 155, 87, 60, 253, 212, 224, 22, 103, 66, 111, 24, 138, 23, 229, 18,
190, 78, 196, 214, 218, 158, 222, 73, 160, 251, 245, 142, 187, 47, 238, 122,
169, 104, 121, 145, 21, 178, 7, 63, 148, 194, 16, 137, 11, 34, 95, 33,
128, 127, 93, 154, 90, 144, 50, 39, 53, 62, 204, 231, 191, 247, 151, 3,
255, 25, 48, 179, 72, 165, 181, 209, 215, 94, 146, 42, 172, 86, 170, 198,
79, 184, 56, 210, 150, 164, 125, 182, 118, 252, 107, 226, 156, 116, 4, 241,
69, 157, 112, 89, 100, 113, 135, 32, 134, 91, 207, 101, 230, 45, 168, 2,
27, 96, 37, 173, 174, 176, 185, 246, 28, 70, 97, 105, 52, 64, 126, 15,
85, 71, 163, 35, 221, 81, 175, 58, 195, 92, 249, 206, 186, 197, 234, 38,
44, 83, 13, 110, 133, 40, 132, 9, 211, 223, 205, 244, 65, 129, 77, 82,
106, 220, 55, 200, 108, 193, 171, 250, 36, 225, 123, 8, 12, 189, 177, 74,
120, 136, 149, 139, 227, 99, 232, 109, 233, 203, 213, 254, 59, 0, 29, 57,
242, 239, 183, 14, 102, 88, 208, 228, 166, 119, 114, 248, 235, 117, 75, 10,
49, 68, 80, 180, 143, 237, 31, 26, 219, 153, 141, 51, 159, 17, 131, 20,
};
{
}
/**
* Initializes the processing of a whole block directly from the input buffer.
*
* This will update the checksum as well as initializing abStateX.
*
* @param pCtx The MD2 context.
* @param pbBlock The block.
*/
{
for (unsigned j = 0; j < RTMD2_BLOCK_SIZE; j++)
{
}
}
/**
* Special version of rtMd2BlockInit that does not update the checksum.
*
* This is used in the final round when adding the checksum to the calculation.
*
* @param pCtx The MD2 context.
* @param pbBlock The block (i.e. the checksum).
*/
{
for (unsigned j = 0; j < RTMD2_BLOCK_SIZE; j++)
{
}
}
/**
* Initalizes the abStateX from a full buffer and update the checksum.
*
* The buffer is part of the abStateX structure (bytes 16 thru 31), so this
* is a somewhat reduced version of rtMd2BlockInit.
*
* @param pCtx The MD2 context.
*/
{
for (unsigned j = 0; j < RTMD2_BLOCK_SIZE; j++)
{
}
}
/**
* Process the current block.
*
* Requires one of the rtMd2BlockInit functions to be called first.
*
* @param pCtx The MD2 context.
*/
{
for (unsigned j = 0; j < 18; j++) /* 18 rounds */
{
for (unsigned k = 0; k < RTMD2_BLOCK_SIZE * 3; k++)
}
}
{
/*
* Deal with buffered bytes first.
*/
{
{
}
else
{
return;
}
}
/*
* Process full blocks directly from the input buffer.
*/
while (cbBuf >= RTMD2_BLOCK_SIZE)
{
}
/*
* Stash any remaining bytes into the context buffer.
*/
if (cbBuf > 0)
{
}
}
{
/*
* Pad the message to a multiple of 16 bytes. This is done even if the
* message already is a multiple of 16.
*/
/*
* Add the checksum.
*/
/*
* Done. Just copy out the digest.
*/
}
{
}