Hi all;
I've understood that in order to accessing each element of
"PrivateKeyArray" or "PublicKeyArray" (of type SecByteBlock),I should
use "[]" operator,(e.g. PrivateKeyArray[i])!
Is it right?
I tried these two different codes in my program:
1)
byte* privkey;
byte* pubkey;
privkey=new byte[PrivateKeyArray.size()];
pubkey=new byte[PublicKeyArray.size()];
memcpy(privkey,PrivateKeyArray,PrivateKeyArray.size());
memcpy(pubkey,PublicKeyArray,PublicKeyArray.size());
Then I would show "privkey" and "pubkey" contents in output with these
codes:
cout<<"PrivateKeyArray is:"<<endl;
HexEncoder(new FileSink(cout)).Put(privkey,sizeof(privkey));
cout<<endl<<endl;
cout<<"PublicKeyArray is:"<<endl;
HexEncoder(new FileSink(cout)).Put(pubkey,sizeof(pubkey));
But I saw this output:
PrivateKeyArray is:
30820275
PublicKeyArray is:
30819D30
Where the actual output should be such below:
PrivateKeyArray is:
30820275020100300D06092A864886F70D01010105000482025F3082025B02010002818100A486F1
B0E79A113B712569EAD38B8F329C467CD3AEF544165A33E4851DCF05766D0136D3A72BB13C1142FD
9940607287242D5FBA4E2E3194ECCEABDC9157FFA3973F96EA698DDEA3D216E3609632DA40174E0A
6BF9F028840AE097DB9D621971C54954E1EFA2B9D92F5FF25854A4091FF369C99A1AC0451B4F8786
28D2DBBA2F0201110281800E84609EAB0610944DBF89587C13D7EDE09CCEC76242D14D4431C1570A
28DAD5BE52EE3FDA0B62763DC2256F67900A1AFBA9A690704F5EBA51214B66490F4B42FFA1A04F28
E9C9D5DF378E099E824070587A079F1766E56EA45481AB3A3188BE62DEF5C8824B0252E7AA8A715D
930090FB761C5AF766A7CD9358F50A4D8340E9024100BF9B76622684205D80F798CD1A9F010247E2
FAE28E39E4FA5DB3CEA3FE622F8A0B6A0A08FA2F89940010233704D453EF7E5E76727F23D37BB17B
1FB36FA76939024100DBD1B25C735ACECE6F5456267724FEEF3A040E7E627D70A3BC19B64DB623DC
24AEAB13F8862115EEEDC30371D5F8596FFDD0BC75FD1103DB181C38009F64C6A70241009285F11D
E137DC83BCF992F73279975C18DABFDA6CC2DC46FC5C52B9A4693369904207AC83154B16D2DF29FC
E5934F3EABEDE21B522A748BC3F4BDE3919E23490241008E3C6459F049D11C29EB46CD98633B8BBC
20BE158B05DF79013DD05066CBE8CC7105492856CA1D403F7E2F67C6AFC166952CB62E3A564DCA00
8ABAD339F5E9F3024017C18FC8A2BCEA07B0BADF52401D8EE91F08975F68DAFBF12FB54C291303D9
4B3AA9643B7973D6B67CA3787F371DFD3A7EE5DBAADF8098382180F071DA64F8A4
PublicKeyArray is:
30819D300D06092A864886F70D010101050003818B0030818702818100A486F1B0E79A113B712569
EAD38B8F329C467CD3AEF544165A33E4851DCF05766D0136D3A72BB13C1142FD9940607287242D5F
BA4E2E3194ECCEABDC9157FFA3973F96EA698DDEA3D216E3609632DA40174E0A6BF9F028840AE097
DB9D621971C54954E1EFA2B9D92F5FF25854A4091FF369C99A1AC0451B4F878628D2DBBA2F020111
2)
byte* privkey;
byte* pubkey;
privkey=new byte[PrivateKeyArray.size()];
pubkey=new byte[PublicKeyArray.size()];
for(int i=0;i<(int)PrivateKeyArray.size();i++)
privkey[i]=PrivateKeyArray[i];
for(int i=0;i<(int)PublicKeyArray.size();i++)
pubkey[i]=PublicKeyArray[i];
cout<<"PrivateKeyArray is:"<<endl;
HexEncoder(new FileSink(cout)).Put(privkey,sizeof(privkey));
cout<<endl<<endl;
cout<<"PublicKeyArray is:"<<endl;
HexEncoder(new FileSink(cout)).Put(pubkey,sizeof(pubkey));
And I saw similar output as below:
PrivateKeyArray is:
30820273
PublicKeyArray is:
30819D30
Why don't "PrivateKeyArray" and "PublicKeyArray" (of type
SecByteBlock) transfer their elements completely into "privkey" and
"pubkey" byte arrays?
Or problem is due to another thing?
I also tried to show "PrivateKeyArray" and "PublicKeyArray" elements
without using "HexEncoder" with these codes:
cout<<"PrivateKeyArray is:"<<endl;
for(int i=0;i<(int)PrivateKeyArray.size();i++)
cout<<PrivateKeyArray[i]<<" | ";
cout<<endl<<"PublicKeyArray is:"<<endl;
for(int i=0;i<(int)PublicKeyArray.size();i++)
cout<<PublicKeyArray[i]<<" | ";
And then,I saw this output:
PrivateKeyArray is:
| ☺ | ☺ | ☺ | ♣ | | ♦ | é | ☻ | _ | 0 | é | ☻ | [ | ☻ | ☺ | | ☻ |
ü | ü |
| ╤ | + | σ | ╖ | x | ╝ | ▐ | s | ╓ | å | ↓ | Ü | r | ─ | ╗ | û | ╨ |
♥ | ↕ | ¼
| ♠ | S | ² | ☼ | ▐ | ↔ | ‼ | 7 | H | | æ | ▒ | ò | ñ | * | d | ^ |
à | í | í
| J | K | A | | q | ⌐ | L | ▼ | A | ■ | Ä | Γ | D | å | º | ╡ | % | K
| G | h |
: | ═ | ä | J | « | e | É | à | ↕ | { | 8 | ^ | ê | $ | Φ | G | z | N
| ┤ | ► |
‼ | - | 5 | ░ | v | ë | / | y | ÿ | h | y | ö | ^ | T | ╠ | ╤ | ┌ | y
| B | h |
ÿ | ♥ | ↔ |
| ô | é | ╔ | 6 | æ | ▬ | ╒ | / | . | p | ^ | ▌ | · | L | ▀ | à | ^ |
ñ | ▲ | ö
| / | ╥ | ⌐ | + | ☻ | ☺ | ◄ | ☻ | ü | Ç | C | ¼ | Q | ┘ | y | Γ | └ |
p | ┼ | g
| ₧ | ▀ | % | ! | ç | ⁿ | ▬ | ▼ | ∟ | í | ◄ | ← | , | 9 | ╓ | δ | I |
√ | L | ☻
| é | ╗ | \ | k | s | å | J | ╙ | ▀ | ╩ | α | E | Q | 1 | ╢ | x | ⁿ |
‼ | ♠ | A
| b | ▐ | ¼ | A | t | 7 | ¢ | h | 3 | Ö | ┐ | º | ├ | C | ë | ╒ | ▬ |
Θ | 8 | f
| 1 | ² | " | ► | « | ┐ | < | ═ | F | ↓ | j | é | ♣ | ↔ | ` | ┬ | ç |
Å | « | ▬
| ╝ | Ω | ► | ü | T | f | 5 | ╒ | z | ÷ | ò | ? | j | " | ü | ☼ | ∙ |
▬ | ] | e
| O | N | « | ╗ | ┴ | ☻ | A | | ┌ | W | ╓ | ó | ├ | 6 | a | ä | < |
' | ↔ | ?
| · | ⌂ | ∙ | | ▐ | ² | → | Æ | r | ! | ☻ | ☻ | ▐ | B | ¥ | ╠ | ♦ |
╓ | └ | K
| + | í | τ | n | : | ª | ÿ | | | ╣ | ▒ | ╩ | Ü | ┌ | e | í | √ | ß |
σ | q | ↕
| ê | û | ê | ¡ | Θ | ~ | & | ▄ | ╝ | 6 | ½ | 1 | ☻ | A | | ⌡ | ? |
▲ | ▲ |
| { | ├ | R | ‼ | ¡ | g | f | # | j | à | { | æ | ▐ | ▀ | = | ░ | - |
n | C | S
| ╟ | ♦ | 5 | ⌂ | L | ↔ | Ä | % | } | ╗ | Γ | ■ | Y | ▓ | ú | ♠ | X
| ) | ♂ | 4
| ≤ | ê | ¶ | R | ` | å | α | { | m | < | ╛ | G | K | ← | ½ | ♀ | ♂ |
ï | ← | ☻
| @ | M | ☼ | ± | f | ƒ | @ | ^ | º | $ | J |
| R | ╨ | ß | ▀ | l | 0 | ò | É | Φ | d | ä | ▲ | ╙ | ╒ | ∙ | d | ▐ |
ÿ | K | ╦
| e | ╙ | * | § | r | 2 | ╤ | b | ■ | ╪ | | í | ▄ | M | ¶ | ╧ | ┬ |
O | ║ | d
| $ | ¿ | ¡ | Ö | ª | ╩ | ß | : | Σ | ~ | ⌐ | Γ | ◄ | ☻ | A | | ü |
╓ | ▼ |
| ╙ | ¶ | X | X | í | ☺ | r | ∙ | ╓ | â | ░ | ¶ | > | * | ▓ | k | ≤ |
█ | ╨ | ÷
| w | Ñ | ÿ | ╤ | | ( | K | ß | ╫ | £ | Ω | | │ | ╒ | " | V | N |
º | $ | ╔
| ▓ | ƒ | ♂ | ╬ | à | ÷ | ▌ | ■ | _ | v | ◄ | ↓ | q | | Ñ | < | o |
╔ | α | ;
| ☻ | A | | ▓ | ñ | ♦ | | | ] | # | _ | | 9 | ò | o | g | » |
g | █ | ç
| P | ┬ | D | ╧ | ÷ | Ω |
| z | ½ | å | W | p | e | £ | µ | » | ╙ | û | ╩ | & | ╣ | > | σ | ╓ |
Ö | : | ▐
| § | e | « | L | 6 | 1 | " | ' | è | : | δ | v | l | é | ) | µ | ▌ |
â | w | i
|
PublicKeyArray is:
| ☺ | ☺ | ☺ | ♣ | | ♥ | ü | ï | | 0 | ü | ç | ☻ | ü | ü | | ╤ |
+ | σ | ╖
| x | ╝ | ▐ | s | ╓ | å | ↓ | Ü | r | ─ | ╗ | û | ╨ | ♥ | ↕ | ¼ | ♠ |
S | ² | ☼
| ▐ | ↔ | ‼ | 7 | H | | æ | ▒ | ò | ñ | * | d | ^ | à | í | í | J |
K | A | |
q | ⌐ | L | ▼ | A | ■ | Ä | Γ | D | å | º | ╡ | % | K | G | h | : | ═
| ä | J |
« | e | É | à | ↕ | { | 8 | ^ | ê | $ | Φ | G | z | N | ┤ | ► | ‼ | -
| 5 | ░ |
v | ë | / | y | ÿ | h | y | ö | ^ | T | ╠ | ╤ | ┌ | y | B | h | ÿ | ♥
| ↔ |
| ô | é | ╔ | 6 | æ | ▬ | ╒ | / | . | p | ^ | ▌ | · | L | ▀ | à | ^ |
ñ | ▲ | ö
| / | ╥ | ⌐ | + | ☻ | ☺ | ◄ |
Anyways,my Main problem is that why don't SecByteBlock objects in this
code,transfer their contents into byte arrays completely?
Is the problem due to using "[]" operator?
(Also I tried "()" operator instead of "[]",but it didn't work!)
I tried so much to solve my problem,but I couldn't unfortunately!
Please guide me;
Thanks in Advance.
Gary.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users"
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at
http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---