Richard Levitte - VMS Whacker wrote:
In message <[EMAIL PROTECTED]> on Thu, 26 Jun 2003 12:55:22 -0400, "Lee Dilkie" <[EMAIL PROTECTED]> said:
OK, I've been follownig this discussion for a while, and it's time I ake action. Basically, to provide for all the current and future ways of handling the IV, I can see three alternatives:
- have the application provide a function that manipulates the IV. - have the application specify exactly which part of the IV is the actual counter (in bit positions, or would byte positions be enough?).
The application specifies 4 datas: 1. a step size 2. a bit mask. 3. a (optional) pointer to a function that is called if the step bits that are not in the bit mask: 4. a (optional) pointer to a function doing the counting;
A quick draft of my idea:
typedef struct _CounterData CounterData; struct _CounterData { Counter_Number nActual; /* the actual counter value */ Counter_Number nStep; /* Step size added each step */ Counter_Number nStepMask;/* Mask indikating when counter leaves range */ int (*Count)(CounterData *pCounter); /* optional: handle a step, returns: < 0: error returns: > 0: OK. */ int (*Range)(CounterData *pCounter); /* optional: is called if Count() returns out of range. returns: < 0: error returns: > 0: OK */ };
int Count(CounterData *pCounter) { if (!pCounter) return -1; pCounter->nActual+= pCounter->nStep; return 1; } int Range_restart(CounterData *pCounter) { if (!pCounter) return -1; pCounter->nActual &= ~pCounter->nStepMask; return 1; } int Range_terminate(CounterData *pCounter) { return -1; }
int Do_Counter(CounterData *pCounter) { int nRet; if (!pCounter) return -1; if (pCounter->Count) nRet = pCounter->Count(pCounter); else nRet = Count(pCounter); if (nRet < 0) return nRet; if (pCounter->nActual & ~pCounter->nStepMask) { if (pCounter->Range) return pCounter->Range(pCounter); else return Range_restart(pCounter); } return nRet; }
OK. The Mask could be an upper bound...
Any comments ?
Bye
Goetz
-- Goetz Babin-Ebell, TC TrustCenter AG, http://www.trustcenter.de Sonninstr. 24-28, 20097 Hamburg, Germany Tel.: +49-(0)40 80 80 26 -0, Fax: +49-(0)40 80 80 26 -126
smime.p7s
Description: S/MIME Cryptographic Signature