seccbce.c revision 40f53fa8d9c6a4fc38c0014495e7a42b08f52481
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews/* Copyright (C) RSA Data Security, Inc. created 1990, 1996. This is an
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews unpublished work protected as such under copyright law. This work
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence contains proprietary, confidential, and trade secret information of
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews RSA Data Security, Inc. Use, disclosure or reproduction without the
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews express written authorization of RSA Data Security, Inc. is
854d0238dbc2908490197984b3b9d558008a53dfMark Andrews/* On first call, it is assumed that *remainderLen is zero.
854d0238dbc2908490197984b3b9d558008a53dfMark Andrews Returns AE_OUTPUT_LEN, 0.
6324997211a5e2d82528dcde98e8981190a35faeMichael Graff (context, xorBlock, remainder, remainderLen, SecretEncrypt, output,
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrewsunsigned char *xorBlock;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrewsunsigned char *remainder;
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrewsunsigned char *output;
f7b99290c31abeb20c55fc55391510450ce60423Mark Andrewsunsigned char *input;
e0a30050c8516a3d54a4f8dcdd88435704a8a3edMark Andrews /* Output length will be all available 8-byte blocks.
add4043305ca411202ed9cf1929a4179016515ceBrian Wellington if ((*outputLen = 8 * (totalLen / 8)) > maxOutputLen)
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence /* Not enough to encrypt, just accumulate into remainder.
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews ((POINTER)remainder + *remainderLen, (POINTER)input, inputLen);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews /* Accumulate enough bytes from input into remainder to encrypt the
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews ((POINTER)remainder + *remainderLen, (POINTER)input,
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews for (i = 0; i < 8; i++)
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews /* Encrypt in place */
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews T_memcpy ((POINTER)xorBlock, (POINTER)output, 8);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews /* Now encrypt the bulk of the input.
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews for (i = 0; i < 8; i++)
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews /* Encrypt in place */
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews T_memcpy ((POINTER)xorBlock, (POINTER)output, 8);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews /* inputLen is now < 8, so copy input to remainder.
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews T_memcpy ((POINTER)remainder, (POINTER)input, inputLen);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews/* This just ensures that *remainderLen is zero.
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff The caller must restart the context (setting remainderLen to zero).
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence Returns AE_INPUT_LEN, 0.