Source Code Cross Referenced for SerialisationTest.java in  » Security » Bouncy-Castle » org » bouncycastle » jce » provider » test » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Security » Bouncy Castle » org.bouncycastle.jce.provider.test 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.bouncycastle.jce.provider.test;
002:
003:        import org.bouncycastle.jce.interfaces.ElGamalPrivateKey;
004:        import org.bouncycastle.jce.interfaces.ElGamalPublicKey;
005:        import org.bouncycastle.util.encoders.Base64;
006:        import org.bouncycastle.util.test.SimpleTest;
007:
008:        import javax.crypto.interfaces.DHPrivateKey;
009:        import javax.crypto.interfaces.DHPublicKey;
010:        import java.io.ByteArrayInputStream;
011:        import java.io.IOException;
012:        import java.io.ObjectInputStream;
013:        import java.math.BigInteger;
014:        import java.security.interfaces.DSAPrivateKey;
015:        import java.security.interfaces.DSAPublicKey;
016:        import java.security.interfaces.RSAPrivateCrtKey;
017:        import java.security.interfaces.RSAPublicKey;
018:
019:        public class SerialisationTest extends SimpleTest {
020:            private static BigInteger mod = new BigInteger(
021:                    "69919157209851583596607278525201743749468350078269839551939850344506918649679");
022:            private static BigInteger pubExp = new BigInteger("65537");
023:            private static BigInteger privExp = new BigInteger(
024:                    "6387323103214694462561419908301918608189256611651974386490887304224030221257");
025:            private static BigInteger crtExp = new BigInteger(
026:                    "49050879172577973803420172068797326635");
027:            private static BigInteger p = new BigInteger(
028:                    "272712035519670228866910009292918035133");
029:            private static BigInteger q = new BigInteger(
030:                    "256384567247338962716621434774670631163");
031:            private static BigInteger expP = new BigInteger(
032:                    "121540093892892992427860713054115232161");
033:            private static BigInteger expQ = new BigInteger(
034:                    "169333445127196347119779037859859594883");
035:
036:            private static byte[] rsaPub = Base64
037:                    .decode("rO0ABXNyAC1vcmcuYm91bmN5Y2FzdGxlLmpjZS5wcm92aWRlci5KQ0VSU0FQdWJsaWNLZXklImoOW/pshAIAAkwAB21vZHV"
038:                            + "sdXN0ABZMamF2YS9tYXRoL0JpZ0ludGVnZXI7TAAOcHVibGljRXhwb25lbnRxAH4AAXhwc3IAFGphdmEubWF0aC5CaWdJbn"
039:                            + "RlZ2VyjPyfH6k7+x0DAAZJAAhiaXRDb3VudEkACWJpdExlbmd0aEkAE2ZpcnN0Tm9uemVyb0J5dGVOdW1JAAxsb3dlc3RTZ"
040:                            + "XRCaXRJAAZzaWdudW1bAAltYWduaXR1ZGV0AAJbQnhyABBqYXZhLmxhbmcuTnVtYmVyhqyVHQuU4IsCAAB4cP//////////"
041:                            + "/////v////4AAAABdXIAAltCrPMX+AYIVOACAAB4cAAAACCalNcvvJNMM944KWzzuH2MXkKbiW10OEzGQb9B9MM/T3hzcQB"
042:                            + "+AAP///////////////7////+AAAAAXVxAH4ABwAAAAMBAAF4");
043:
044:            private static byte[] rsaPriv = Base64
045:                    .decode("rO0ABXNyADFvcmcuYm91bmN5Y2FzdGxlLmpjZS5wcm92aWRlci5KQ0VSU0FQcml2YXRlQ3J0S2V5bLqHzgJzVS4CAAZMAA5"
046:                            + "jcnRDb2VmZmljaWVudHQAFkxqYXZhL21hdGgvQmlnSW50ZWdlcjtMAA5wcmltZUV4cG9uZW50UHEAfgABTAAOcHJpbWVFeH"
047:                            + "BvbmVudFFxAH4AAUwABnByaW1lUHEAfgABTAAGcHJpbWVRcQB+AAFMAA5wdWJsaWNFeHBvbmVudHEAfgABeHIALm9yZy5ib"
048:                            + "3VuY3ljYXN0bGUuamNlLnByb3ZpZGVyLkpDRVJTQVByaXZhdGVLZXlG6wnAB89BHAMABEwAB21vZHVsdXNxAH4AAUwAEHBr"
049:                            + "Y3MxMkF0dHJpYnV0ZXN0ABVMamF2YS91dGlsL0hhc2h0YWJsZTtMAA5wa2NzMTJPcmRlcmluZ3QAEkxqYXZhL3V0aWwvVmV"
050:                            + "jdG9yO0wAD3ByaXZhdGVFeHBvbmVudHEAfgABeHBzcgAUamF2YS5tYXRoLkJpZ0ludGVnZXKM/J8fqTv7HQMABkkACGJpdE"
051:                            + "NvdW50SQAJYml0TGVuZ3RoSQATZmlyc3ROb256ZXJvQnl0ZU51bUkADGxvd2VzdFNldEJpdEkABnNpZ251bVsACW1hZ25pd"
052:                            + "HVkZXQAAltCeHIAEGphdmEubGFuZy5OdW1iZXKGrJUdC5TgiwIAAHhw///////////////+/////gAAAAF1cgACW0Ks8xf4"
053:                            + "BghU4AIAAHhwAAAAIJqU1y+8k0wz3jgpbPO4fYxeQpuJbXQ4TMZBv0H0wz9PeHNyABNqYXZhLnV0aWwuSGFzaHRhYmxlE7s"
054:                            + "PJSFK5LgDAAJGAApsb2FkRmFjdG9ySQAJdGhyZXNob2xkeHA/QAAAAAAACHcIAAAACwAAAAB4c3IAEGphdmEudXRpbC5WZW"
055:                            + "N0b3LZl31bgDuvAQMAA0kAEWNhcGFjaXR5SW5jcmVtZW50SQAMZWxlbWVudENvdW50WwALZWxlbWVudERhdGF0ABNbTGphd"
056:                            + "mEvbGFuZy9PYmplY3Q7eHAAAAAAAAAAAHVyABNbTGphdmEubGFuZy5PYmplY3Q7kM5YnxBzKWwCAAB4cAAAAApwcHBwcHBw"
057:                            + "cHBweHNxAH4ABv///////////////v////4AAAABdXEAfgAKAAAAIA4fGMVoocAtYNiamDRvnzBmMv/l8FibkQsOUJjxrmP"
058:                            + "JeHhzcQB+AAb///////////////7////+AAAAAXVxAH4ACgAAABAk5tsPIq2YfF0nfLPvAKUreHNxAH4ABv////////////"
059:                            + "///v////4AAAABdXEAfgAKAAAAEFtvxUfS67k0bWmAU9/geaF4c3EAfgAG///////////////+/////gAAAAF1cQB+AAoAA"
060:                            + "AAQf2RvbOpsxhCjGK1vhd7+g3hzcQB+AAb///////////////7////+AAAAAXVxAH4ACgAAABDNKm1zRn/cYal03dRjdxK9"
061:                            + "eHNxAH4ABv///////////////v////4AAAABdXEAfgAKAAAAEMDh3xza3MJ4XNak/35BYPt4c3EAfgAG///////////////"
062:                            + "+/////gAAAAF1cQB+AAoAAAADAQABeA==");
063:
064:            private static BigInteger elGamalY = new BigInteger(
065:                    "89822212135401014750127909969755994242838935150891306006689219384134393835581");
066:            private static BigInteger elGamalX = new BigInteger(
067:                    "23522982289275336984843296896007818700866293719703239515258104457243931686357");
068:            private static BigInteger elGamalG = new BigInteger(
069:                    "29672625807664138507782226105202719390719480236799714903174779490259822385963");
070:            private static BigInteger elGamalP = new BigInteger(
071:                    "98263422916834911205348180460395783697757584103849580149025105739079617780363");
072:
073:            private static byte[] elGamalPub = Base64
074:                    .decode("rO0ABXNyADFvcmcuYm91bmN5Y2FzdGxlLmpjZS5wcm92aWRlci5KQ0VFbEdhbWFsUHVibGljS2V5eOnUVVUsZjQDAAJMAAZ"
075:                            + "lbFNwZWN0ADBMb3JnL2JvdW5jeWNhc3RsZS9qY2Uvc3BlYy9FbEdhbWFsUGFyYW1ldGVyU3BlYztMAAF5dAAWTGphdmEvbW"
076:                            + "F0aC9CaWdJbnRlZ2VyO3hwc3IAFGphdmEubWF0aC5CaWdJbnRlZ2VyjPyfH6k7+x0DAAZJAAhiaXRDb3VudEkACWJpdExlb"
077:                            + "md0aEkAE2ZpcnN0Tm9uemVyb0J5dGVOdW1JAAxsb3dlc3RTZXRCaXRJAAZzaWdudW1bAAltYWduaXR1ZGV0AAJbQnhyABBq"
078:                            + "YXZhLmxhbmcuTnVtYmVyhqyVHQuU4IsCAAB4cP///////////////v////4AAAABdXIAAltCrPMX+AYIVOACAAB4cAAAACD"
079:                            + "GlZIJNbVQCnj4wiR0o8gGbKtJEWJBllz8NAELXcqwPXhzcQB+AAT///////////////7////+AAAAAXVxAH4ACAAAACDZPy"
080:                            + "BetQ1Ed8NUnTfXb+MBhFVK1KRe2LzQP7oVz2Kai3hzcQB+AAT///////////////7////+AAAAAXVxAH4ACAAAACBBmhxth"
081:                            + "0FhU4SsG01Wjyi1dlZFZvOy1zFC12XRGO8bK3h4");
082:
083:            private static byte[] elGamalPriv = Base64
084:                    .decode("rO0ABXNyADJvcmcuYm91bmN5Y2FzdGxlLmpjZS5wcm92aWRlci5KQ0VFbEdhbWFsUHJpdmF0ZUtleULhxV+2vMBOAwAETAA"
085:                            + "GZWxTcGVjdAAwTG9yZy9ib3VuY3ljYXN0bGUvamNlL3NwZWMvRWxHYW1hbFBhcmFtZXRlclNwZWM7TAAQcGtjczEyQXR0cm"
086:                            + "lidXRlc3QAFUxqYXZhL3V0aWwvSGFzaHRhYmxlO0wADnBrY3MxMk9yZGVyaW5ndAASTGphdmEvdXRpbC9WZWN0b3I7TAABe"
087:                            + "HQAFkxqYXZhL21hdGgvQmlnSW50ZWdlcjt4cHNyABRqYXZhLm1hdGguQmlnSW50ZWdlcoz8nx+pO/sdAwAGSQAIYml0Q291"
088:                            + "bnRJAAliaXRMZW5ndGhJABNmaXJzdE5vbnplcm9CeXRlTnVtSQAMbG93ZXN0U2V0Qml0SQAGc2lnbnVtWwAJbWFnbml0dWR"
089:                            + "ldAACW0J4cgAQamF2YS5sYW5nLk51bWJlcoaslR0LlOCLAgAAeHD///////////////7////+AAAAAXVyAAJbQqzzF/gGCF"
090:                            + "TgAgAAeHAAAAAgNAGJQeYfM6ToYoA3ePFdEe7yh8hKecr+WZA0AwxrtdV4c3EAfgAG///////////////+/////gAAAAF1c"
091:                            + "QB+AAoAAAAg2T8gXrUNRHfDVJ0312/jAYRVStSkXti80D+6Fc9imot4c3EAfgAG///////////////+/////gAAAAF1cQB+"
092:                            + "AAoAAAAgQZocbYdBYVOErBtNVo8otXZWRWbzstcxQtdl0RjvGyt4eA==");
093:
094:            private static BigInteger dhY = new BigInteger(
095:                    "1925747248304483170395506065378568192931506039297732684689153183373019672434");
096:            private static BigInteger dhX = new BigInteger("3");
097:            private static BigInteger dhG = new BigInteger(
098:                    "3493483775405590747011712302510626058005717040655777294576367636428413099058");
099:            private static BigInteger dhP = new BigInteger(
100:                    "106557663805518855012633095511067237673895862256610675920943888960856082029127");
101:
102:            private static byte[] dhPub = Base64
103:                    .decode("rO0ABXNyACxvcmcuYm91bmN5Y2FzdGxlLmpjZS5wcm92aWRlci5KQ0VESFB1YmxpY0tlefz+KCkPI+T8AwACTAAGZGhTcGV"
104:                            + "jdAAjTGphdmF4L2NyeXB0by9zcGVjL0RIUGFyYW1ldGVyU3BlYztMAAF5dAAWTGphdmEvbWF0aC9CaWdJbnRlZ2VyO3hwc3"
105:                            + "IAFGphdmEubWF0aC5CaWdJbnRlZ2VyjPyfH6k7+x0DAAZJAAhiaXRDb3VudEkACWJpdExlbmd0aEkAE2ZpcnN0Tm9uemVyb"
106:                            + "0J5dGVOdW1JAAxsb3dlc3RTZXRCaXRJAAZzaWdudW1bAAltYWduaXR1ZGV0AAJbQnhyABBqYXZhLmxhbmcuTnVtYmVyhqyV"
107:                            + "HQuU4IsCAAB4cP///////////////v////4AAAABdXIAAltCrPMX+AYIVOACAAB4cAAAACAEQe8vYXxZPS5oAUy0e0yRYxK"
108:                            + "EAO3GjhMWZKNw8flvcnhzcQB+AAT///////////////7////+AAAAAXVxAH4ACAAAACDrlYAb5zOABHPgsK6oIKtMFgPD3v"
109:                            + "nbTosOnokaSVsaR3hzcQB+AAT///////////////7////+AAAAAXVxAH4ACAAAACAHuT3jEhOVRGfaKdFOX6J2vDYxiMPQW"
110:                            + "ljjL/3Xz85cMnh3BAAAAAB4");
111:
112:            private static byte[] dhPriv = Base64
113:                    .decode("rO0ABXNyAC1vcmcuYm91bmN5Y2FzdGxlLmpjZS5wcm92aWRlci5KQ0VESFByaXZhdGVLZXkEURpYQRlitAMABEwABmRoU3B"
114:                            + "lY3QAI0xqYXZheC9jcnlwdG8vc3BlYy9ESFBhcmFtZXRlclNwZWM7TAAQcGtjczEyQXR0cmlidXRlc3QAFUxqYXZhL3V0aW"
115:                            + "wvSGFzaHRhYmxlO0wADnBrY3MxMk9yZGVyaW5ndAASTGphdmEvdXRpbC9WZWN0b3I7TAABeHQAFkxqYXZhL21hdGgvQmlnS"
116:                            + "W50ZWdlcjt4cHNyABRqYXZhLm1hdGguQmlnSW50ZWdlcoz8nx+pO/sdAwAGSQAIYml0Q291bnRJAAliaXRMZW5ndGhJABNm"
117:                            + "aXJzdE5vbnplcm9CeXRlTnVtSQAMbG93ZXN0U2V0Qml0SQAGc2lnbnVtWwAJbWFnbml0dWRldAACW0J4cgAQamF2YS5sYW5"
118:                            + "nLk51bWJlcoaslR0LlOCLAgAAeHD///////////////7////+AAAAAXVyAAJbQqzzF/gGCFTgAgAAeHAAAAABA3hzcQB+AA"
119:                            + "b///////////////7////+AAAAAXVxAH4ACgAAACDrlYAb5zOABHPgsK6oIKtMFgPD3vnbTosOnokaSVsaR3hzcQB+AAb//"
120:                            + "/////////////7////+AAAAAXVxAH4ACgAAACAHuT3jEhOVRGfaKdFOX6J2vDYxiMPQWljjL/3Xz85cMnh3BAAAAAB4");
121:
122:            private static BigInteger dsaY = new BigInteger(
123:                    "6189794363048388077684611193598066807847399153242870209962581468350882042922904596556915269714052441467859854436813271130403014368908908961326314287317209");
124:            private static BigInteger dsaX = new BigInteger(
125:                    "45673695048287886591258561084679393738177012644");
126:            private static BigInteger dsaG = new BigInteger(
127:                    "3245524385217980657302535456606469153364622623109429686740209357408427939040123729832874550911504858612362156241316117434271994372338032643547044203024422");
128:            private static BigInteger dsaP = new BigInteger(
129:                    "8836853285188714261909188099204635517862922237850722644742752953058083563923137941667883080809922365262319540202714582925718707421743492259382127680083261");
130:
131:            private static byte[] dsaPub = Base64
132:                    .decode("rO0ABXNyAC1vcmcuYm91bmN5Y2FzdGxlLmpjZS5wcm92aWRlci5KREtEU0FQdWJsaWNLZXkYUfY34kLIBwMAAkwAB2RzYVN"
133:                            + "wZWN0ACRMamF2YS9zZWN1cml0eS9pbnRlcmZhY2VzL0RTQVBhcmFtcztMAAF5dAAWTGphdmEvbWF0aC9CaWdJbnRlZ2VyO3"
134:                            + "hwc3IAFGphdmEubWF0aC5CaWdJbnRlZ2VyjPyfH6k7+x0DAAZJAAhiaXRDb3VudEkACWJpdExlbmd0aEkAE2ZpcnN0Tm9ue"
135:                            + "mVyb0J5dGVOdW1JAAxsb3dlc3RTZXRCaXRJAAZzaWdudW1bAAltYWduaXR1ZGV0AAJbQnhyABBqYXZhLmxhbmcuTnVtYmVy"
136:                            + "hqyVHQuU4IsCAAB4cP///////////////v////4AAAABdXIAAltCrPMX+AYIVOACAAB4cAAAAEB2LxWpG2UqKz0HcWZwDii"
137:                            + "fO0+3sXqWwmnAnHw8HbPRbtJUozr0As4FX7loWxvWyV+CJDse2KwdxISyMmq6hMDZeHNxAH4ABP///////////////v////"
138:                            + "4AAAABdXEAfgAIAAAAQKi5o5xNZaCAFFAV6dWnHHjG0TVoA7d34RUNF0GhquH6BH/W3BvW4fy428+NPnCgUvJM9iLBTpuBn"
139:                            + "oepupEE1T14c3EAfgAE///////////////+/////gAAAAF1cQB+AAgAAAAU/tVyr5rbnY4WkK7C6NK21c9jn8V4c3EAfgAE"
140:                            + "///////////////+/////gAAAAF1cQB+AAgAAABAPffK8RBcfUspb5PsGDyjZf4Tqcmo5UhuaABmUnq8Vqb3P7jc1+LNaTh"
141:                            + "mUJSnjWQ4+kyCeeJgPH9d3iBd5blQJnh4");
142:
143:            private static byte[] dsaPriv = Base64
144:                    .decode("rO0ABXNyAC5vcmcuYm91bmN5Y2FzdGxlLmpjZS5wcm92aWRlci5KREtEU0FQcml2YXRlS2V5vxcJOSU9rboDAANMAAthdHR"
145:                            + "yQ2FycmllcnQAPUxvcmcvYm91bmN5Y2FzdGxlL2pjZS9wcm92aWRlci9QS0NTMTJCYWdBdHRyaWJ1dGVDYXJyaWVySW1wbD"
146:                            + "tMAAdkc2FTcGVjdAAkTGphdmEvc2VjdXJpdHkvaW50ZXJmYWNlcy9EU0FQYXJhbXM7TAABeHQAFkxqYXZhL21hdGgvQmlnS"
147:                            + "W50ZWdlcjt4cHNyABRqYXZhLm1hdGguQmlnSW50ZWdlcoz8nx+pO/sdAwAGSQAIYml0Q291bnRJAAliaXRMZW5ndGhJABNm"
148:                            + "aXJzdE5vbnplcm9CeXRlTnVtSQAMbG93ZXN0U2V0Qml0SQAGc2lnbnVtWwAJbWFnbml0dWRldAACW0J4cgAQamF2YS5sYW5"
149:                            + "nLk51bWJlcoaslR0LlOCLAgAAeHD///////////////7////+AAAAAXVyAAJbQqzzF/gGCFTgAgAAeHAAAAAUCAAUTkau3a"
150:                            + "uChEXbN4isGH4aY6R4c3EAfgAF///////////////+/////gAAAAF1cQB+AAkAAABAqLmjnE1loIAUUBXp1acceMbRNWgDt"
151:                            + "3fhFQ0XQaGq4foEf9bcG9bh/Ljbz40+cKBS8kz2IsFOm4Geh6m6kQTVPXhzcQB+AAX///////////////7////+AAAAAXVx"
152:                            + "AH4ACQAAABT+1XKvmtudjhaQrsLo0rbVz2OfxXhzcQB+AAX///////////////7////+AAAAAXVxAH4ACQAAAEA998rxEFx"
153:                            + "9Sylvk+wYPKNl/hOpyajlSG5oAGZSerxWpvc/uNzX4s1pOGZQlKeNZDj6TIJ54mA8f13eIF3luVAmeHNyABNqYXZhLnV0aW"
154:                            + "wuSGFzaHRhYmxlE7sPJSFK5LgDAAJGAApsb2FkRmFjdG9ySQAJdGhyZXNob2xkeHA/QAAAAAAACHcIAAAACwAAAAB4c3IAE"
155:                            + "GphdmEudXRpbC5WZWN0b3LZl31bgDuvAQMAA0kAEWNhcGFjaXR5SW5jcmVtZW50SQAMZWxlbWVudENvdW50WwALZWxlbWVu"
156:                            + "dERhdGF0ABNbTGphdmEvbGFuZy9PYmplY3Q7eHAAAAAAAAAAAHVyABNbTGphdmEubGFuZy5PYmplY3Q7kM5YnxBzKWwCAAB"
157:                            + "4cAAAAApwcHBwcHBwcHBweHg=");
158:
159:            public String getName() {
160:                return "Serialisation";
161:            }
162:
163:            public void performTest() throws Exception {
164:                rsaTest();
165:                elGamalTest();
166:                dhTest();
167:                dsaTest();
168:            }
169:
170:            private void rsaTest() throws IOException, ClassNotFoundException {
171:                RSAPublicKey pub = (RSAPublicKey) readObject(rsaPub);
172:
173:                if (!mod.equals(pub.getModulus())) {
174:                    fail("public key modulus mismatch");
175:                }
176:                if (!pubExp.equals(pub.getPublicExponent())) {
177:                    fail("public key exponent mismatch");
178:                }
179:
180:                RSAPrivateCrtKey priv = (RSAPrivateCrtKey) readObject(rsaPriv);
181:
182:                if (!mod.equals(priv.getModulus())) {
183:                    fail("private key modulus mismatch");
184:                }
185:                if (!privExp.equals(priv.getPrivateExponent())) {
186:                    fail("private key exponent mismatch");
187:                }
188:                if (!p.equals(priv.getPrimeP())) {
189:                    fail("private key p mismatch");
190:                }
191:                if (!q.equals(priv.getPrimeQ())) {
192:                    fail("private key q mismatch");
193:                }
194:                if (!expP.equals(priv.getPrimeExponentP())) {
195:                    fail("private key p exponent mismatch");
196:                }
197:                if (!expQ.equals(priv.getPrimeExponentQ())) {
198:                    fail("private key q exponent mismatch");
199:                }
200:                if (!crtExp.equals(priv.getCrtCoefficient())) {
201:                    fail("private key crt exponent mismatch");
202:                }
203:            }
204:
205:            private void elGamalTest() throws IOException,
206:                    ClassNotFoundException {
207:                ElGamalPublicKey pub = (ElGamalPublicKey) readObject(elGamalPub);
208:
209:                if (!elGamalY.equals(pub.getY())) {
210:                    fail("public key y mismatch");
211:                }
212:                if (!elGamalG.equals(pub.getParameters().getG())) {
213:                    fail("public key g mismatch");
214:                }
215:                if (!elGamalP.equals(pub.getParameters().getP())) {
216:                    fail("public key p mismatch");
217:                }
218:
219:                ElGamalPrivateKey priv = (ElGamalPrivateKey) readObject(elGamalPriv);
220:
221:                if (!elGamalX.equals(priv.getX())) {
222:                    fail("private key x mismatch");
223:                }
224:                if (!elGamalG.equals(priv.getParameters().getG())) {
225:                    fail("private key g mismatch");
226:                }
227:                if (!elGamalP.equals(priv.getParameters().getP())) {
228:                    fail("private key p mismatch");
229:                }
230:            }
231:
232:            private void dhTest() throws IOException, ClassNotFoundException {
233:                DHPublicKey pub = (DHPublicKey) readObject(dhPub);
234:
235:                if (!dhY.equals(pub.getY())) {
236:                    fail("dh public key y mismatch");
237:                }
238:                if (!dhG.equals(pub.getParams().getG())) {
239:                    fail("dh public key g mismatch");
240:                }
241:                if (!dhP.equals(pub.getParams().getP())) {
242:                    fail("dh public key p mismatch");
243:                }
244:                if (0 != pub.getParams().getL()) {
245:                    fail("dh public key l mismatch");
246:                }
247:
248:                DHPrivateKey priv = (DHPrivateKey) readObject(dhPriv);
249:
250:                if (!dhX.equals(priv.getX())) {
251:                    fail("dh private key x mismatch");
252:                }
253:                if (!dhG.equals(priv.getParams().getG())) {
254:                    fail("dh private key g mismatch");
255:                }
256:                if (!dhP.equals(priv.getParams().getP())) {
257:                    fail("dh private key p mismatch");
258:                }
259:                if (0 != priv.getParams().getL()) {
260:                    fail("dh private key l mismatch");
261:                }
262:            }
263:
264:            private void dsaTest() throws IOException, ClassNotFoundException {
265:                DSAPublicKey pub = (DSAPublicKey) readObject(dsaPub);
266:
267:                if (!dsaY.equals(pub.getY())) {
268:                    fail("dsa public key y mismatch");
269:                }
270:                if (!dsaG.equals(pub.getParams().getG())) {
271:                    fail("dsa public key g mismatch");
272:                }
273:                if (!dsaP.equals(pub.getParams().getP())) {
274:                    fail("dsa public key p mismatch");
275:                }
276:
277:                DSAPrivateKey priv = (DSAPrivateKey) readObject(dsaPriv);
278:
279:                if (!dsaX.equals(priv.getX())) {
280:                    fail("dsa private key x mismatch");
281:                }
282:                if (!dsaG.equals(priv.getParams().getG())) {
283:                    fail("dsa private key g mismatch");
284:                }
285:                if (!dsaP.equals(priv.getParams().getP())) {
286:                    fail("dsa private key p mismatch");
287:                }
288:            }
289:
290:            private Object readObject(byte[] key) throws IOException,
291:                    ClassNotFoundException {
292:                ObjectInputStream oIn = new ObjectInputStream(
293:                        new ByteArrayInputStream(key));
294:
295:                return oIn.readObject();
296:            }
297:
298:            public static void main(String[] args) {
299:                runTest(new SerialisationTest());
300:            }
301:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.