bigacc.c revision 65c4736d9c0ebc6d9b1d991593b55566909da9cd
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence/* Copyright (C) RSA Data Security, Inc. created 1987, 1996. This is an
431a83fb29482c5170b3e4026e59bb14849a6707Tinderbox User unpublished work protected as such under copyright law. This work
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews contains proprietary, confidential, and trade secret information of
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence RSA Data Security, Inc. Use, disclosure or reproduction without the
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater express written authorization of RSA Data Security, Inc. is
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence prohibited.
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence */
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews#include "global.h"
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews#include "bigmath.h"
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews/* Returns carry: vector a = b * vector c.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews */
dafcb997e390efa4423883dafd100c975c4095d6Mark AndrewsUINT2 BigAcc (a, b, c, n)
dafcb997e390efa4423883dafd100c975c4095d6Mark AndrewsUINT2 *a;
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrenceunsigned int b;
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David LawrenceUINT2 *c;
adfc3ad3ce5db585fdb29d3d6000aa05ba077f13Evan Huntunsigned int n;
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein{
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein UINT4 bTemp, result = (UINT4)0;
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence register unsigned int i;
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence if (!b)
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence return (0);
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence
6b7257f756eb0530cdf54df9a7fab8d51a5001c3David Lawrence bTemp = b;
6b7257f756eb0530cdf54df9a7fab8d51a5001c3David Lawrence for (i = 0; i < n; i++) {
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence result += bTemp * ((UINT4) c[i]);
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence result += ((UINT4) a[i]);
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington a[i] = (UINT2) result;
ce2be9b7211ab5bacaa10fe74ef35def3a3f6089David Lawrence result >>= 16;
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence }
73a691c373488e4f70387a62462cd8ce0d991705David Lawrence return ((UINT2)result);
8f66dad9393ae0724f758c4a51e06ff55c2d1219Brian Wellington}
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews