cantobig.c revision 65c4736d9c0ebc6d9b1d991593b55566909da9cd
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer/* Copyright (C) RSA Data Security, Inc. created 1990, 1996. This is an
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer unpublished work protected as such under copyright law. This work
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer contains proprietary, confidential, and trade secret information of
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer RSA Data Security, Inc. Use, disclosure or reproduction without the
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer express written authorization of RSA Data Security, Inc. is
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer/* CanonicalToBig () copies a byte vector into a word vector while REVERSING
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer the order of significance. The byte vector is input MSByte first while
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer the word vector is written out LSWord first. It also adds a leading zero
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer sign bit if necessary.
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer Returns 0, AE_DATA.
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyerint CanonicalToBig (wordPointer, wordCount, bytePointer, numBytes)
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer if (A_IntegerBits (bytePointer, numBytes) / 16 + 1 > wordCount)
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer /* start at end of byte vector */
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer /* copy as much as possible */
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer copyCount = (wordCount < numBytes / 2) ? wordCount : numBytes / 2;
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer /* Copy two bytes.*/
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer *wordPointer++ = (UINT2)*bytePointer + (*(bytePointer - 1) << 8);
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer /* If the number of input bytes was odd. Copy one last byte.*/
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer /* zero fill remainder of word vector */