Developer Reference for Intel® Integrated Performance Primitives Cryptography 2018

Add_BN

Adds two integer big numbers.

Syntax

IppStatus ippsAdd_BN(IppsBigNumState *a, IppsBigNumState *b, IppsBigNumState * r);

Include Files

ippcp.h

Parameters

a

First integer big number of the data type IppsBigNumState.

b

Second integer big number of the data type IppsBigNumState.

r

Addition result.

Description

The function adds two integer big numbers regardless of their signs and sizes and returns the result of the operation.

The following pseudocode represents this function:

(*r) (*a) + (*b).

Return Values

ippStsNoErr

Indicates no error. Any other value indicates an error or warning.

ippStsNullPtrErr

Indicates an error condition if any of the specified pointers is NULL.

ippStsOutOfRangeErr

Indicates an error condition if the size of r is smaller than the resulting data length.

Note

The function executes only under the condition that size of IppsBigNumState *r is not less than either the length of IppsBigNumState *a or that of IppsBigNumState *b.

Example

The code example below adds big numbers.

void Add_BN_sample(void){
   // define and set up Big Number A
   const Ipp32u bnuA[] = {0x01234567,0x9abcdeff,0x11223344};
   IppsBigNumState* bnA = New_BN(sizeof(bnuA)/sizeof(Ipp32u));
   // define and set up Big Number B
   const Ipp32u bnuB[] = {0x76543210,0xfedcabee,0x44332211};
   IppsBigNumState* bnB = New_BN(sizeof(bnuB)/sizeof(Ipp32u), bnuB);
   // define Big Number R
   int sizeR = max(sizeof(bnuA), sizeof(bnuB));
   IppsBigNumState* bnR = New_BN(1+sizeR/sizeof(Ipp32u));
   // R = A+B
   ippsAdd_BN(bnA, bnB, bnR);
   // type R
   Type_BN("R=A+B:\n", bnR);
   delete [] (Ipp8u*)bnA;
   delete [] (Ipp8u*)bnB;
   delete [] (Ipp8u*)bnR;
}