Community
cancel
Showing results for 
Search instead for 
Did you mean: 
achrzesz2
New Contributor I
74 Views

cryptography manual: Type_BN - wrong results

#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
74 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
Reply