Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.
Announcements
FPGA community forums and blogs have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.

cryptography manual: Type_BN - wrong results

achrzesz2
New Contributor I
852 Views
#include "ippcp.h"
#include
void Type_BN(const char* pMsg, const IppsBigNumState* pBN){
using namespace std;
int size;
ippsGetSize_BN(pBN, &size);
Ipp8u* bnValue = new Ipp8u [size*4];
ippsGetOctString_BN(bnValue, size*4, pBN);
if(pMsg)
cout < for(int n=0; n cout<<<(int)bnValue;
cout < delete [] bnValue;
}
int main(){
using namespace std ;
Ipp32u A[] = {0x0,0x1};
int sizeWords=(sizeof A)/4;
int ctxSize;
ippsBigNumGetSize(sizeWords, &ctxSize);
IppsBigNumState* BNA = (IppsBigNumState*) (new Ipp8u [ctxSize] );
ippsBigNumInit(sizeWords, BNA);
ippsSet_BN(IppsBigNumPOS, sizeWords, A, BNA);
Type_BN("A: ",BNA); //
delete [] (Ipp8u*) BNA;
return 0;}
//Output:
//A: 00010000

//should be A: 100000000

A. Chrzeszczyk
0 Kudos
1 Reply
achrzesz2
New Contributor I
852 Views
Hi
One simple possible improvement is:

void Type_BN(const char* pMsg, const IppsBigNumState* pBN){
using namespace std;
int size;
ippsGetSize_BN(pBN, &size);
Ipp8u* bnValue = new Ipp8u [size*4];
ippsGetOctString_BN(bnValue, size*4, pBN);
if(pMsg)
cout < cout.fill('0'); //*********************************
for(int n=0; n cout.width(2); //*********************************
cout<<<(int)bnValue;
}
cout.fill(' '); //********************************
cout < delete [] bnValue;
}

// Output of previous main():
//A: 0000000100000000


A Chrzeszczyk
0 Kudos
Reply