35
35
import javax .crypto .*;
36
36
37
37
import jdk .test .lib .SecurityTools ;
38
- import sun . security . util . HexDumpEncoder ;
38
+ import jdk . test . lib . hexdump . HexPrinter ;
39
39
40
40
/*
41
41
* Confirm interoperability of RSA public keys between SunMSCAPI and SunJCE
@@ -84,29 +84,29 @@ static void run() throws Exception {
84
84
System .out .println ();
85
85
86
86
byte [] plain = new byte [] {0x01 , 0x02 , 0x03 , 0x04 , 0x05 };
87
- HexDumpEncoder hde = new HexDumpEncoder ();
88
- System .out .println ("Plaintext:\n " + hde . encode (plain ) + "\n " );
87
+ HexPrinter hp = HexPrinter . simple ();
88
+ System .out .println ("Plaintext:\n " + hp . toString (plain ) + "\n " );
89
89
90
90
Cipher rsa = Cipher .getInstance ("RSA/ECB/PKCS1Padding" );
91
91
rsa .init (Cipher .ENCRYPT_MODE , myPuKey );
92
92
byte [] encrypted = rsa .doFinal (plain );
93
93
System .out .println ("Encrypted plaintext using RSA Cipher from " +
94
94
rsa .getProvider ().getName () + " JCE provider\n " );
95
- System .out .println (hde . encode (encrypted ) + "\n " );
95
+ System .out .println (hp . toString (encrypted ) + "\n " );
96
96
97
97
Cipher rsa2 = Cipher .getInstance ("RSA/ECB/PKCS1Padding" , "SunMSCAPI" );
98
98
rsa2 .init (Cipher .ENCRYPT_MODE , myPuKey );
99
99
byte [] encrypted2 = rsa2 .doFinal (plain );
100
100
System .out .println ("Encrypted plaintext using RSA Cipher from " +
101
101
rsa2 .getProvider ().getName () + " JCE provider\n " );
102
- System .out .println (hde . encode (encrypted2 ) + "\n " );
102
+ System .out .println (hp . toString (encrypted2 ) + "\n " );
103
103
104
104
Cipher rsa3 = Cipher .getInstance ("RSA/ECB/PKCS1Padding" , "SunMSCAPI" );
105
105
rsa3 .init (Cipher .DECRYPT_MODE , myPrKey );
106
106
byte [] decrypted = rsa3 .doFinal (encrypted );
107
107
System .out .println ("Decrypted first ciphertext using RSA Cipher from " +
108
108
rsa3 .getProvider ().getName () + " JCE provider\n " );
109
- System .out .println (hde . encode (decrypted ) + "\n " );
109
+ System .out .println (hp . toString (decrypted ) + "\n " );
110
110
if (! Arrays .equals (plain , decrypted )) {
111
111
throw new Exception ("First decrypted ciphertext does not match " +
112
112
"original plaintext" );
@@ -115,7 +115,7 @@ static void run() throws Exception {
115
115
decrypted = rsa3 .doFinal (encrypted2 );
116
116
System .out .println ("Decrypted second ciphertext using RSA Cipher from "
117
117
+ rsa3 .getProvider ().getName () + " JCE provider\n " );
118
- System .out .println (hde . encode (decrypted ) + "\n " );
118
+ System .out .println (hp . toString (decrypted ) + "\n " );
119
119
if (! Arrays .equals (plain , decrypted )) {
120
120
throw new Exception ("Second decrypted ciphertext does not match " +
121
121
"original plaintext" );
0 commit comments