Source Code Cross Referenced for PGPDSATest.java in  » Security » Bouncy-Castle » org » bouncycastle » openpgp » 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.openpgp.test 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.bouncycastle.openpgp.test;
002:
003:        import org.bouncycastle.bcpg.BCPGOutputStream;
004:        import org.bouncycastle.bcpg.HashAlgorithmTags;
005:        import org.bouncycastle.bcpg.PublicKeyAlgorithmTags;
006:        import org.bouncycastle.jce.provider.BouncyCastleProvider;
007:        import org.bouncycastle.openpgp.PGPCompressedData;
008:        import org.bouncycastle.openpgp.PGPCompressedDataGenerator;
009:        import org.bouncycastle.openpgp.PGPKeyPair;
010:        import org.bouncycastle.openpgp.PGPLiteralData;
011:        import org.bouncycastle.openpgp.PGPLiteralDataGenerator;
012:        import org.bouncycastle.openpgp.PGPObjectFactory;
013:        import org.bouncycastle.openpgp.PGPOnePassSignature;
014:        import org.bouncycastle.openpgp.PGPOnePassSignatureList;
015:        import org.bouncycastle.openpgp.PGPPrivateKey;
016:        import org.bouncycastle.openpgp.PGPPublicKey;
017:        import org.bouncycastle.openpgp.PGPPublicKeyRing;
018:        import org.bouncycastle.openpgp.PGPSecretKeyRing;
019:        import org.bouncycastle.openpgp.PGPSignature;
020:        import org.bouncycastle.openpgp.PGPSignatureGenerator;
021:        import org.bouncycastle.openpgp.PGPSignatureList;
022:        import org.bouncycastle.openpgp.PGPSignatureSubpacketGenerator;
023:        import org.bouncycastle.openpgp.PGPUserAttributeSubpacketVector;
024:        import org.bouncycastle.openpgp.PGPUtil;
025:        import org.bouncycastle.util.encoders.Base64;
026:        import org.bouncycastle.util.test.SimpleTest;
027:        import org.bouncycastle.util.test.UncloseableOutputStream;
028:
029:        import java.io.ByteArrayInputStream;
030:        import java.io.ByteArrayOutputStream;
031:        import java.io.InputStream;
032:        import java.io.OutputStream;
033:        import java.security.KeyFactory;
034:        import java.security.KeyPair;
035:        import java.security.KeyPairGenerator;
036:        import java.security.PrivateKey;
037:        import java.security.Security;
038:        import java.util.Date;
039:        import java.util.Iterator;
040:
041:        public class PGPDSATest extends SimpleTest {
042:            byte[] testPubKey = Base64
043:                    .decode("mQGiBD9HBzURBACzkxRCVGJg5+Ld9DU4Xpnd4LCKgMq7YOY7Gi0EgK92gbaa6+zQ"
044:                            + "oQFqz1tt3QUmpz3YVkm/zLESBBtC1ACIXGggUdFMUr5I87+1Cb6vzefAtGt8N5VV"
045:                            + "1F/MXv1gJz4Bu6HyxL/ncfe71jsNhav0i4yAjf2etWFj53zK6R+Ojg5H6wCgpL9/"
046:                            + "tXVfGP8SqFvyrN/437MlFSUEAIN3V6j/MUllyrZglrtr2+RWIwRrG/ACmrF6hTug"
047:                            + "Ol4cQxaDYNcntXbhlTlJs9MxjTH3xxzylyirCyq7HzGJxZzSt6FTeh1DFYzhJ7Qu"
048:                            + "YR1xrSdA6Y0mUv0ixD5A4nPHjupQ5QCqHGeRfFD/oHzD4zqBnJp/BJ3LvQ66bERJ"
049:                            + "mKl5A/4uj3HoVxpb0vvyENfRqKMmGBISycY4MoH5uWfb23FffsT9r9KL6nJ4syLz"
050:                            + "aRR0gvcbcjkc9Z3epI7gr3jTrb4d8WPxsDbT/W1tv9bG/EHawomLcihtuUU68Uej"
051:                            + "6/wZot1XJqu2nQlku57+M/V2X1y26VKsipolPfja4uyBOOyvbLQzRXJpYyBFY2hp"
052:                            + "ZG5hIChEU0EgVGVzdCBLZXkpIDxlcmljQGJvdW5jeWNhc3RsZS5vcmc+iFkEExEC"
053:                            + "ABkFAj9HBzUECwcDAgMVAgMDFgIBAh4BAheAAAoJEM0j9enEyjRDAlwAn2rrom0s"
054:                            + "MhufWK5vIRwg7gj5qsLEAJ4vnT5dPBVblofsG+pDoCVeJXGGng==");
055:
056:            byte[] testPrivKey = Base64
057:                    .decode("lQHhBD9HBzURBACzkxRCVGJg5+Ld9DU4Xpnd4LCKgMq7YOY7Gi0EgK92gbaa6+zQ"
058:                            + "oQFqz1tt3QUmpz3YVkm/zLESBBtC1ACIXGggUdFMUr5I87+1Cb6vzefAtGt8N5VV"
059:                            + "1F/MXv1gJz4Bu6HyxL/ncfe71jsNhav0i4yAjf2etWFj53zK6R+Ojg5H6wCgpL9/"
060:                            + "tXVfGP8SqFvyrN/437MlFSUEAIN3V6j/MUllyrZglrtr2+RWIwRrG/ACmrF6hTug"
061:                            + "Ol4cQxaDYNcntXbhlTlJs9MxjTH3xxzylyirCyq7HzGJxZzSt6FTeh1DFYzhJ7Qu"
062:                            + "YR1xrSdA6Y0mUv0ixD5A4nPHjupQ5QCqHGeRfFD/oHzD4zqBnJp/BJ3LvQ66bERJ"
063:                            + "mKl5A/4uj3HoVxpb0vvyENfRqKMmGBISycY4MoH5uWfb23FffsT9r9KL6nJ4syLz"
064:                            + "aRR0gvcbcjkc9Z3epI7gr3jTrb4d8WPxsDbT/W1tv9bG/EHawomLcihtuUU68Uej"
065:                            + "6/wZot1XJqu2nQlku57+M/V2X1y26VKsipolPfja4uyBOOyvbP4DAwIDIBTxWjkC"
066:                            + "GGAWQO2jy9CTvLHJEoTO7moHrp1FxOVpQ8iJHyRqZzLllO26OzgohbiPYz8u9qCu"
067:                            + "lZ9Xn7QzRXJpYyBFY2hpZG5hIChEU0EgVGVzdCBLZXkpIDxlcmljQGJvdW5jeWNh"
068:                            + "c3RsZS5vcmc+iFkEExECABkFAj9HBzUECwcDAgMVAgMDFgIBAh4BAheAAAoJEM0j"
069:                            + "9enEyjRDAlwAnjTjjt57NKIgyym7OTCwzIU3xgFpAJ0VO5m5PfQKmGJRhaewLSZD"
070:                            + "4nXkHg==");
071:
072:            byte[] testPrivKey2 = Base64
073:                    .decode("lQHhBEAnoewRBADRvKgDhbV6pMzqYfUgBsLxSHzmycpuxGbjMrpyKHDOEemj"
074:                            + "iQb6TyyBKUoR28/pfshFP9R5urtKIT7wjVrDuOkxYkgRhNm+xmPXW2Lw3D++"
075:                            + "MQrC5VWe8ywBltz6T9msmChsaKo2hDhIiRI/mg9Q6rH9pJKtVGi4R7CgGxM2"
076:                            + "STQ5fwCgub38qGS1W2O4hUsa+3gva5gaNZUEAItegda4/H4t88XdWxW3D8pv"
077:                            + "RnFz26/ADdImVaQlBoumD15VmcgYoT1Djizey7X8vfV+pntudESzLbn3GHlI"
078:                            + "6C09seH4e8eYP63t7KU/qbUCDomlSswd1OgQ/RxfN86q765K2t3K1i3wDSxe"
079:                            + "EgSRyGKee0VNvOBFOFhuWt+patXaBADE1riNkUxg2P4lBNWwu8tEZRmsl/Ys"
080:                            + "DBIzXBshoMzZCvS5PnNXMW4G3SAaC9OC9jvKSx9IEWhKjfjs3QcWzXR28mcm"
081:                            + "5na0bTxeOMlaPPhBdkTCmFl0IITWlH/pFlR2ah9WYoWYhZEL2tqB82wByzxH"
082:                            + "SkSeD9V5oeSCdCcqiqkEmv4DAwLeNsQ2XGJVRmA4lld+CR5vRxpT/+/2xklp"
083:                            + "lxVf/nx0+thrHDpro3u/nINIIObk0gh59+zaEEe3APlHqbQVYWFhIGJiYiA8"
084:                            + "Y2NjQGRkZC5lZWU+iFoEExECABoFAkAnoewFCwcDAgEDFQIDAxYCAQIeAQIX"
085:                            + "gAAKCRA5nBpCS63az85BAKCbPfU8ATrFvkXhzGNGlc1BJo6DWQCgnK125xVK"
086:                            + "lWLpt6ZJJ7TXcx3nkm6wAgAAnQFXBEAnoe0QBACsQxPvaeBcv2TkbgU/5Wc/"
087:                            + "tO222dPE1mxFbXjGTKfb+6ge96iyD8kTRLrKCkEEeVBa8AZqMSoXUVN6tV8j"
088:                            + "/zD8Bc76o5iJ6wgpg3Mmy2GxInVfsfZN6/G3Y2ukmouz+CDNvQdUw8cTguIb"
089:                            + "QoV3XhQ03MLbfVmNcHsku9F4CuKNWwADBQP0DSSe8v5PXF9CSCXOIxBDcQ5x"
090:                            + "RKjyYOveqoH/4lbOV0YNUbIDZq4RaUdotpADuPREFmWf0zTB6KV/WIiag8XU"
091:                            + "WU9zdDvLKR483Bo6Do5pDBcN+NqfQ+ntGY9WJ7BSFnhQ3+07i1K+NsfFTRfv"
092:                            + "hf9X3MP75rCf7MxAIWHTabEmUf4DAwLeNsQ2XGJVRmA8DssBUCghogG9n8T3"
093:                            + "qfBeKsplGyCcF+JjPeQXkKQaoYGJ0aJz36qFP9d8DuWtT9soQcqIxVf6mTa8"
094:                            + "kN1594hGBBgRAgAGBQJAJ6HtAAoJEDmcGkJLrdrPpMkAnRyjQSKugz0YJqOB"
095:                            + "yGasMLQLxd2OAKCEIlhtCarlufVQNGZsuWxHVbU8crACAAA=");
096:
097:            byte[] sig1 = Base64
098:                    .decode("owGbwMvMwCR4VvnryyOnTJwZ10gncZSkFpfolVSU2Ltz78hIzcnJVyjPL8pJUeTq"
099:                            + "sGdmZQCJwpQLMq3ayTA/0Fj3xf4jbwPfK/H3zj55Z9L1n2k/GOapKJrvMZ4tLiCW"
100:                            + "GtP/XeDqX4fORDUA");
101:
102:            byte[] sig1crc = Base64.decode("OZa/");
103:
104:            byte[] testPubWithUserAttr = Base64
105:                    .decode("mQGiBD2Rqv0RBADqKCkhVEtB/lEEr/9CubuHEy2oN/yU5j+2GXSdcNdVnRI/rwFy"
106:                            + "fHEQIk3uU7zHSUKFrC59yDm0sODYyjEdE3BVb0xvEJ5LE/OdndcIMXT1DungZ1vB"
107:                            + "zIK/3lr33W/PHixYxv9jduH3WrTehBpiKkgMZp8XloSFj2Cnw9LDyfqB7QCg/8K1"
108:                            + "o2k75NkOd9ZjnA9ye7Ri3bEEAKyr61Mo7viPWBK1joWAEsxG0OBWM+iSlG7kwh31"
109:                            + "8efgC/7Os6x4Y0jzs8mpcbBjeZtZjS9lRbfp7RinhF269xL0TZ3JxIdtaAV/6yDQ"
110:                            + "9NXfZY9dskN++HIR/5GCEEgq/qTJZt6ti5k7aV19ZFfO6wiK3NUy08wOrVsdOkVE"
111:                            + "w9IcBADaplhpcel3201uU3OCboogJtw81R5MJMZ4Y9cKL/ca2jGISn0nA7KrAw9v"
112:                            + "ShheSixGO4BV9JECkLEbtg7i+W/j/De6S+x2GLNcphuTP3UmgtKbhs0ItRqzW561"
113:                            + "s6gLkqi6aWmgaFLd8E1pMJcd9DSY95P13EYB9VJIUxFNUopzo7QcUmFsZiBIYXVz"
114:                            + "ZXIgPGhhdXNlckBhY20ub3JnPokAWAQQEQIAGAUCPZGq/QgLAwkIBwIBCgIZAQUb"
115:                            + "AwAAAAAKCRAqIBiOh4JvOKg4AJ9j14yygOqqzqiLKeaasIzqT8LCIgCggx14WuLO"
116:                            + "wOUTUswTaVKMFnU7tseJAJwEEAECAAYFAj2Rqx8ACgkQ9aWTKMpUDFV+9QP/RiWT"
117:                            + "5FAF5Rgb7beaApsgXsME+Pw7HEYFtqGa6VcXEpbcUXO6rjaXsgMgY90klWlWCF1T"
118:                            + "HOyKITvj2FdhE+0j8NQn4vaGpiTwORW/zMf/BZ0abdSWQybp10Yjs8gXw30UheO+"
119:                            + "F1E524MC+s2AeUi2hwHMiS+AVYd4WhxWHmWuBpTRypP/AAALTgEQAAEBAAAAAQAA"
120:                            + "AAABAAAA/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAoHBwgHBgoICAgLCgoLDhgQ"
121:                            + "Dg0NDh0VFhEYIx8lJCIfIiEmKzcvJik0KSEiMEExNDk7Pj4+JS5ESUM8SDc9Pjv/"
122:                            + "2wBDAQoLCw4NDhwQEBw7KCIoOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7"
123:                            + "Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozv/wAARCABqAF0DASIAAhEBAxEB/8QAHwAAAQUB"
124:                            + "AQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQID"
125:                            + "AAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0"
126:                            + "NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKT"
127:                            + "lJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl"
128:                            + "5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL"
129:                            + "/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHB"
130:                            + "CSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpj"
131:                            + "ZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3"
132:                            + "uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIR"
133:                            + "AxEAPwD2aiiq9xcxWsRllcKqjOT06E/0oAsVm6jrmm6VGXvLuOPGflz8x+grzXxV"
134:                            + "8U51u5LXRgBGowZHXknnkc9OQcV51caneXdw9xPOXlckl2AJHY4J6cD1oA9J1z4p"
135:                            + "TRkrYQhRyQ0hIY5/2QRx7k9ulczN8SvEEshdZkX0UorDrznI759a5Mksckkknqec"
136:                            + "mkoA7WD4oavEoEttbTepYEZ+mCMVv6H8SLTULhbe/gFozAYkD5Unp3Ax/kV5XRQB"
137:                            + "9EAhgCDkHkEcgilryTwd4zn0m4WzvpTJZSMBuY5MfbueletKyugZWDKwyCOc/j3o"
138:                            + "AduyWLDeWB5Ynj8jSUUUAdFXn/xU15dO0RbGGYC5uWwUB6L1Jx+n413F1cJa2stz"
139:                            + "J92JC5+gGa+bdfvp9S1q4urmRneQg5Yk4HGAPYZoAzySxySSSep5yaSvQvAPhOHU"
140:                            + "rB7u5iLGUlIwQRx7HPr/AJ9LGsfC+dJGngc+X12gc8nvx1/rQB5rRXS3Xg28t9ye"
141:                            + "VLvA7Ddj8MDt6Vnx6JKJCsocnBwqqQSOxPH+fWgDKorTl0SaLGXxkZ+ZcZ4z1yfb"
142:                            + "P1qg0MqLueN1A6kqRigCOvVPh74mF9YjS7tgLi3GIm6b17c+oOfrXlda3haeW38R"
143:                            + "WjxfeMgBOCcD/PHpzQB7nRRRQBqarZjUNLubPJXz4yhI64PFfO3iDRrnRtdm0+cq"
144:                            + "0ocEbehzyOv1xX0vXnHxU8Kf2hYf23aRk3VsMTAZO6MZ5x7UAbfga1W00WzjRSF8"
145:                            + "kbsg5z744HT/ADmuoysikdQSVP8AI1yPgq6il0axk27V8sDcTg5x7V1qSxOcJIrH"
146:                            + "/ZOaAKV5p8JgJSPJGMr97PNcxqOiRXLiRI8nONoIGO55z/8AqyeldhPcQxwyOzoQ"
147:                            + "owRkflXH6t4q0nTLjy57mNXfJCA5x+Qx0NAGXd6LD5iiaPYwTAAx07+vXvXOXmiR"
148:                            + "Qu6u5VTk/MQQV7cdvxPT866KbxTpt7HGR8p7SMw5HuOP8/Ws/ULlb2No0bKMOGBJ"
149:                            + "BHrjHHXn6D8QDzWZQk8iAYVWIA9K6LwDZNeeJ4sEqsaF2YHBHpz2/wA/WsG+V0vZ"
150:                            + "kkGGVsEZz9OcntXffC62iiS7vJTsklKxRFuAw6nBP+eKAPRKKKKAOiqOSNJYzHIo"
151:                            + "ZGGCD0NSUUAeRajIunwzQG4e3tYZTHGsPzOxJ6ADuQcH8Pw5v+19Q0rVJVgl1JG3"
152:                            + "cxykEj13cnHT1r1C38OQ3l063cIkkhmkZDKSeCfx9R/kVLeeGIRKs7hVVDn5OCx9"
153:                            + "yeTjqMf0oAo3k1xP4biuJFeKV4w7gDaQcen1/wAjt5gbK81HW41kIiJBZppULe47"
154:                            + "eoxx+YzivW9Vh/0FAE+XPIJGCOR0rnbPT7eG+LyxlkAG1wQSPXrjvg9MfjQBycNj"
155:                            + "4hMRZgJkUjETQqAy/UAY6DoO/wCNbVlYTNbSNJbmBlBwoUfM30B7j2/lz20VhbKA"
156:                            + "wHmZOQWbOfyrO1G3jil8tBhWToOcdu+c/wAvagDzbUdGlu9aRxFiB/vsuBggZOfq"
157:                            + "cfWujSIR2dnNZTEeXKgMcb4BUHjofbjNKmI5juiabaGGxVJLcdh/nFWtI0oxagsD"
158:                            + "DIkkWXYp4VQDnOemSfyHbigDtgSQMjBI6HqKKKKAOiopoPXjGKdQBnXLiDUI5SMK"
159:                            + "VwxHGf8APFUtW1A+YkMKmbnc23njuf6D/ObWquoaNSQCM/rwP1rMYxxTGWR1UsoU"
160:                            + "biAcdep+o/KgDG1LxdpracIirCVRjaykHr6cHGQe1cv/AGjNcXBW3sntyT/rHcjj"
161:                            + "Hp6Z+nQdAK6PXIdIvcE3Fv5rEfNgP9eRn8c8d/rgzX2i2sqo1y8745CD5WPseOnH"
162:                            + "f8aANiz1O9gjiR5FMUhAV1wcH0Ix6jHHSrMsskz7pGy2MZNc8PEEM7xxWsM/lr8r"
163:                            + "b4jtI9CcHt7nr7Vqi4JuEjB2qse9y2Ace47dRn/OQDMuRMl8RHw7SgDBPGT6jpwf"
164:                            + "yzXa2NmbYF3IMrDB2kkAe3HP5Vwk99u1hdg3ANuOOOB0z6ZwPz6c8eiAhgCDkHkE"
165:                            + "cgigBaKKKAOiqJiMEb9mBknjim3LFIGcOU285ArNa8mKIN3QclScn6+/FADL9xOc"
166:                            + "K2Tj7xAxnAwQPqOmawdSNpeSJBfQyGNXwQpIAPvjqOPyPT12nYsxYnJIGSeMnHP+"
167:                            + "e9UL7TUumEqOYp1GNw6N/vDv/wDXoA5+70vSbFGlhtopUxkBl3EZ45z7/kKwTdpN"
168:                            + "cIsOmeSCduUiCnB9cdeg/M/j0v8AbFtY5hu0gjmGSRICT19cdMDt3+lULzxPZGZv"
169:                            + "LXcBnCrwB6Y4PX+ZoAptMRbiMDAGSSMksf8A9Q6DuKzJtVYs+BvcPgMTkEdOTnrx"
170:                            + "/KoLzVmvZZQjjaT82DyPbqcdx+GKitLf7TNsLYAGWPfH+TQBcsYJDE0rOyu4wjHk"
171:                            + "gfQ+p/zzWjpnja5sdSOm6yyK0Z2pMCQjZ+6SM9CCMdhnp3E1hYy393FaW0eXfjAx"
172:                            + "gAdT26D+X4Vg/EuFLbxOsCYBitkQkEdsgcADsB+lAHplvqUbsu5vlYA5PIB7468e"
173:                            + "nPf8lfUlDkRRrIvqZNn6EV41o3iO/wBFcCJ/MhBP7pjwD6g9ua7G08b6TcRl7h5L"
174:                            + "eTPKvGz5+hUH9cUAeo3uFDrt+Y4O7HOOB69Pr/8AXqhUlx/r2/z2qOgBCQoJJwBy"
175:                            + "SeABXHeIfHVvbXcemaW4luHlVJJlIKxjODgg8nqKq/Em6uItOhWOeVAx5CuRnrXn"
176:                            + "+jf8hyw/6+Y//QhQB6xrmlxzXc0NyuHVyQcdjnBz379D1BGeK5u88LMJGlt2RlX7"
177:                            + "qkEsPXn6/pXo/ilVzbttG7DDOOeornqAONbRpI4v3pKOQcAqQD+Y/P6j052NK0p5"
178:                            + "HWHy3IBPyqrfN6gZz+P4/hpXoGzOOiP/ACNdH4XRftsp2jIBxx70AX9E0pdMtvMm"
179:                            + "VRNt5xyEGOgPf3NeDeLdVOs+J768zlGkKx+yjgfy/WvoPXeNEvMcfujXzJQAUUUU"
180:                            + "Af/ZiQBGBBARAgAGBQI9katEAAoJECogGI6Hgm84xz8AoNGz1fJrVPxqkBrUDmWA"
181:                            + "GsP6qVGYAJ0ZOftw/GfQHzdGR8pOK85DLUPEErQkUmFsZiBIYXVzZXIgPGhhdXNl"
182:                            + "ckBwcml2YXNwaGVyZS5jb20+iQBGBBARAgAGBQI9katmAAoJECogGI6Hgm84m0oA"
183:                            + "oJS3CTrgpqRZfhgPtHGtUVjRCJbbAJ9stJgPcbqA2xXEg9yl2TQToWdWxbQkUmFs"
184:                            + "ZiBIYXVzZXIgPGhhdXNlckBwcml2YXNwaGVyZS5vcmc+iQBGBBARAgAGBQI9kauJ"
185:                            + "AAoJECogGI6Hgm84GfAAnRswktLMzDfIjv6ni76Qp5B850byAJ90I0LEHOLhda7r"
186:                            + "kqTwZ8rguNssUrQkUmFsZiBIYXVzZXIgPGhhdXNlckBwcml2YXNwaGVyZS5uZXQ+"
187:                            + "iQBGBBARAgAGBQI9kaubAAoJECogGI6Hgm84zi0An16C4s/B9Z0/AtfoN4ealMh3"
188:                            + "i3/7AJ9Jg4GOUqGCGRRKUA9Gs5pk8yM8GbQmUmFsZiBDLiBIYXVzZXIgPHJhbGZo"
189:                            + "YXVzZXJAYmx1ZXdpbi5jaD6JAEYEEBECAAYFAj2Rq8oACgkQKiAYjoeCbzhPOACg"
190:                            + "iiTohKuIa66FNiI24mQ+XR9nTisAoLmh3lJf16/06qLPsRd9shTkLfmHtB9SYWxm"
191:                            + "IEhhdXNlciA8cmFsZmhhdXNlckBnbXguY2g+iQBGBBARAgAGBQI9kavvAAoJECog"
192:                            + "GI6Hgm84ZE8An0RlgL8mPBa/P08S5e/lD35MlDdgAJ99pjCeY46S9+nVyx7ACyKO"
193:                            + "SZ4OcLQmUmFsZiBIYXVzZXIgPGhhdXNlci5yYWxmQG15c3VucmlzZS5jaD6JAEYE"
194:                            + "EBECAAYFAj2RrEEACgkQKiAYjoeCbzjz0wCg+q801XrXk+Rf+koSI50MW5OaaKYA"
195:                            + "oKOVA8SLxE29qSR/bJeuW0ryzRLqtCVSYWxmIEhhdXNlciA8aGF1c2VyLnJhbGZA"
196:                            + "ZnJlZXN1cmYuY2g+iQBGBBARAgAGBQI9kaxXAAoJECogGI6Hgm848zoAnRBtWH6e"
197:                            + "fTb3is63s8J2zTfpsyS0AKDxTjl+ZZV0COHLrSCaNLZVcpImFrkEDQQ9kar+EBAA"
198:                            + "+RigfloGYXpDkJXcBWyHhuxh7M1FHw7Y4KN5xsncegus5D/jRpS2MEpT13wCFkiA"
199:                            + "tRXlKZmpnwd00//jocWWIE6YZbjYDe4QXau2FxxR2FDKIldDKb6V6FYrOHhcC9v4"
200:                            + "TE3V46pGzPvOF+gqnRRh44SpT9GDhKh5tu+Pp0NGCMbMHXdXJDhK4sTw6I4TZ5dO"
201:                            + "khNh9tvrJQ4X/faY98h8ebByHTh1+/bBc8SDESYrQ2DD4+jWCv2hKCYLrqmus2UP"
202:                            + "ogBTAaB81qujEh76DyrOH3SET8rzF/OkQOnX0ne2Qi0CNsEmy2henXyYCQqNfi3t"
203:                            + "5F159dSST5sYjvwqp0t8MvZCV7cIfwgXcqK61qlC8wXo+VMROU+28W65Szgg2gGn"
204:                            + "VqMU6Y9AVfPQB8bLQ6mUrfdMZIZJ+AyDvWXpF9Sh01D49Vlf3HZSTz09jdvOmeFX"
205:                            + "klnN/biudE/F/Ha8g8VHMGHOfMlm/xX5u/2RXscBqtNbno2gpXI61Brwv0YAWCvl"
206:                            + "9Ij9WE5J280gtJ3kkQc2azNsOA1FHQ98iLMcfFstjvbzySPAQ/ClWxiNjrtVjLhd"
207:                            + "ONM0/XwXV0OjHRhs3jMhLLUq/zzhsSlAGBGNfISnCnLWhsQDGcgHKXrKlQzZlp+r"
208:                            + "0ApQmwJG0wg9ZqRdQZ+cfL2JSyIZJrqrol7DVes91hcAAgIQAKD9MGkS8SUD2irI"
209:                            + "AiwVHU0WXLBnk2CvvueSmT9YtC34UKkIkDPZ7VoeuXDfqTOlbiE6T16zPvArZfbl"
210:                            + "JGdrU7HhsTdu+ADxRt1dPur0G0ICJ3pBD3ydGWpdLI/94x1BvTY4rsR5mS4YWmpf"
211:                            + "e2kWc7ZqezhP7Xt9q7m4EK456ddeUZWtkwGU+PKyRAZ+CK82Uhouw+4aW0NjiqmX"
212:                            + "hfH9/BUhI1P/8R9VkTfAFGPmZzqoHr4AuO5tLRLD2RFSmQCP8nZTiP9nP+wBBvn7"
213:                            + "vuqKRQsj9PwwPD4V5SM+kpW+rUIWr9TZYl3UqSnlXlpEZFd2Bfl6NloeH0cfU69E"
214:                            + "gtjcWGvGxYKPS0cg5yhVb4okka6RqIPQiYl6eJgv4tRTKoPRX29o0aUVdqVvDr5u"
215:                            + "tnFzcINq7jTo8GiO8Ia3cIFWfo0LyQBd1cf1U+eEOz+DleEFqyljaz9VCbDPE4GP"
216:                            + "o+ALESBlOwn5daUSaah9iU8aVPaSjn45hoQqxOKPwJxnCKKQ01iy0Gir+CDU8JJB"
217:                            + "7bmbvQN4bke30EGAeED3oi+3VaBHrhjYLv7SHIxP5jtCJKWMJuLRV709HsWJi3kn"
218:                            + "fGHwH+yCDF8+PDeROAzpXBaD2EFhKgeUTjP5Rgn6ltRf8TQnfbW4qlwyiXMhPOfC"
219:                            + "x6qNmwaFPKQJpIkVq5VGfRXAERfkiQBMBBgRAgAMBQI9kar+BRsMAAAAAAoJECog"
220:                            + "GI6Hgm84CDMAoNrNeP4c8XqFJnsLLPcjk5YGLaVIAKCrL5KFuLQVIp7d0Fkscx3/"
221:                            + "7DGrzw==");
222:
223:            byte[] aesSecretKey = Base64
224:                    .decode("lQHpBEBSdIYRBADpd7MeIxRk4RsvyMnJNIYe4FiVv6i7I7+LPRvnIjDct0bN"
225:                            + "1gCV48QFej7g/PsvXRjYSowV3VIvchWX8OERd/5i10cLbcs7X52EP1vwYaLj"
226:                            + "uRfNUBg8Q51RQsKR+/rBmnVsi68rjU4yTH6wpo6FOO4pz4wFV+tWwGOwOitA"
227:                            + "K31L4wCgqh59eFFBrOlRFAbDvaL7emoCIR8EAOLxDKiLQJYQrKZfXdZnifeo"
228:                            + "dhEP0uuV4O5TG6nrqkhWffzC9cSoFD0BhMl979d8IB2Uft4FNvQc2u8hbJL5"
229:                            + "7OCGDCUAidlB9jSdu0/J+kfRaTGhYDjBgw7AA42576BBSMNouJg/aOOQENEN"
230:                            + "Nn4n7NxR3viBzIsL/OIeU8HSkBgaA/41PsvcgZ3kwpdltJ/FVRWhmMmv/q/X"
231:                            + "qp1YOnF8xPU9bv2ofELrxJfRsbS4GW1etzD+nXs/woW4Vfixs01x+cutR4iF"
232:                            + "3hw+eU+yLToMPmmo8D2LUvX1SRODJpx5yBBeRIYv6nz9H3sQRDx3kaLASxDV"
233:                            + "jTxKmrLYnZz5w5qyVpvRyv4JAwKyWlhdblPudWBFXNkW5ydKn0AV2f51wEtj"
234:                            + "Zy0aLIeutVMSJf1ytLqjFqrnFe6pdJrHO3G00TE8OuFhftWosLGLbEGytDtF"
235:                            + "cmljIEguIEVjaGlkbmEgKHRlc3Qga2V5IC0gQUVTMjU2KSA8ZXJpY0Bib3Vu"
236:                            + "Y3ljYXN0bGUub3JnPohZBBMRAgAZBQJAUnSGBAsHAwIDFQIDAxYCAQIeAQIX"
237:                            + "gAAKCRBYt1NnUiCgeFKaAKCiqtOO+NQES1gJW6XuOGmSkXt8bQCfcuW7SXZH"
238:                            + "zxK1FfdcG2HEDs3YEVawAgAA");
239:
240:            byte[] aesPublicKey = Base64
241:                    .decode("mQGiBEBSdIYRBADpd7MeIxRk4RsvyMnJNIYe4FiVv6i7I7+LPRvnIjDct0bN"
242:                            + "1gCV48QFej7g/PsvXRjYSowV3VIvchWX8OERd/5i10cLbcs7X52EP1vwYaLj"
243:                            + "uRfNUBg8Q51RQsKR+/rBmnVsi68rjU4yTH6wpo6FOO4pz4wFV+tWwGOwOitA"
244:                            + "K31L4wCgqh59eFFBrOlRFAbDvaL7emoCIR8EAOLxDKiLQJYQrKZfXdZnifeo"
245:                            + "dhEP0uuV4O5TG6nrqkhWffzC9cSoFD0BhMl979d8IB2Uft4FNvQc2u8hbJL5"
246:                            + "7OCGDCUAidlB9jSdu0/J+kfRaTGhYDjBgw7AA42576BBSMNouJg/aOOQENEN"
247:                            + "Nn4n7NxR3viBzIsL/OIeU8HSkBgaA/41PsvcgZ3kwpdltJ/FVRWhmMmv/q/X"
248:                            + "qp1YOnF8xPU9bv2ofELrxJfRsbS4GW1etzD+nXs/woW4Vfixs01x+cutR4iF"
249:                            + "3hw+eU+yLToMPmmo8D2LUvX1SRODJpx5yBBeRIYv6nz9H3sQRDx3kaLASxDV"
250:                            + "jTxKmrLYnZz5w5qyVpvRyrQ7RXJpYyBILiBFY2hpZG5hICh0ZXN0IGtleSAt"
251:                            + "IEFFUzI1NikgPGVyaWNAYm91bmN5Y2FzdGxlLm9yZz6IWQQTEQIAGQUCQFJ0"
252:                            + "hgQLBwMCAxUCAwMWAgECHgECF4AACgkQWLdTZ1IgoHhSmgCfU83BLBF2nCua"
253:                            + "zk2dXB9zO1l6XS8AnA07U4cq5W0GrKM6/kP9HWtPhgOFsAIAAA==");
254:
255:            byte[] twofishSecretKey = Base64
256:                    .decode("lQHpBEBSdtIRBACf7WfrqTl8F051+EbaljPf/8/ajFpAfMq/7p3Hri8OCsuc"
257:                            + "fJJIufEEOV1/Lt/wkN67MmSyrU0fUCsRbEckRiB4EJ0zGHVFfAnku2lzdgc8"
258:                            + "AVounqcHOmqA/gliFDEnhYOx3bOIAOav+yiOqfKVBhWRCpFdOTE+w/XoDM+p"
259:                            + "p8bH5wCgmP2FuWpzfSut7GVKp51xNEBRNuED/3t2Q+Mq834FVynmLKEmeXB/"
260:                            + "qtIz5reHEQR8eMogsOoJS3bXs6v3Oblj4in1gLyTVfcID5tku6kLP20xMRM2"
261:                            + "zx2oRbz7TyOCrs15IpRXyqqJxUWD8ipgJPkPXE7hK8dh4YSTUi4i5a1ug8xG"
262:                            + "314twlPzrchpWZiutDvZ+ks1rzOtBACHrEFG2frUu+qVkL43tySE0cV2bnuK"
263:                            + "LVhXbpzF3Qdkfxou2nuzsCbl6m87OWocJX8uYcQGlHLKv8Q2cfxZyieLFg6v"
264:                            + "06LSFdE9drGBWz7mbrT4OJjxPyvnkffPfLOOqae3PMYIIuscvswuhm4X5aoj"
265:                            + "KJs01YT3L6f0iIj03hCeV/4KAwLcGrxT3X0qR2CZyZYSVBdjXeNYKXuGBtOf"
266:                            + "ood26WOtwLw4+l9sHVoiXNv0LomkO58ndJRPGCeZWZEDMVrfkS7rcOlktDxF"
267:                            + "cmljIEguIEVjaGlkbmEgKHRlc3Qga2V5IC0gdHdvZmlzaCkgPGVyaWNAYm91"
268:                            + "bmN5Y2FzdGxlLm9yZz6IWQQTEQIAGQUCQFJ20gQLBwMCAxUCAwMWAgECHgEC"
269:                            + "F4AACgkQaCCMaHh9zR2+RQCghcQwlt4B4YmNxp2b3v6rP3E8M0kAn2Gspi4u"
270:                            + "A/ynoqnC1O8HNlbjPdlVsAIAAA==");
271:
272:            byte[] twofishPublicKey = Base64
273:                    .decode("mQGiBEBSdtIRBACf7WfrqTl8F051+EbaljPf/8/ajFpAfMq/7p3Hri8OCsuc"
274:                            + "fJJIufEEOV1/Lt/wkN67MmSyrU0fUCsRbEckRiB4EJ0zGHVFfAnku2lzdgc8"
275:                            + "AVounqcHOmqA/gliFDEnhYOx3bOIAOav+yiOqfKVBhWRCpFdOTE+w/XoDM+p"
276:                            + "p8bH5wCgmP2FuWpzfSut7GVKp51xNEBRNuED/3t2Q+Mq834FVynmLKEmeXB/"
277:                            + "qtIz5reHEQR8eMogsOoJS3bXs6v3Oblj4in1gLyTVfcID5tku6kLP20xMRM2"
278:                            + "zx2oRbz7TyOCrs15IpRXyqqJxUWD8ipgJPkPXE7hK8dh4YSTUi4i5a1ug8xG"
279:                            + "314twlPzrchpWZiutDvZ+ks1rzOtBACHrEFG2frUu+qVkL43tySE0cV2bnuK"
280:                            + "LVhXbpzF3Qdkfxou2nuzsCbl6m87OWocJX8uYcQGlHLKv8Q2cfxZyieLFg6v"
281:                            + "06LSFdE9drGBWz7mbrT4OJjxPyvnkffPfLOOqae3PMYIIuscvswuhm4X5aoj"
282:                            + "KJs01YT3L6f0iIj03hCeV7Q8RXJpYyBILiBFY2hpZG5hICh0ZXN0IGtleSAt"
283:                            + "IHR3b2Zpc2gpIDxlcmljQGJvdW5jeWNhc3RsZS5vcmc+iFkEExECABkFAkBS"
284:                            + "dtIECwcDAgMVAgMDFgIBAh4BAheAAAoJEGggjGh4fc0dvkUAn2QGdNk8Wrrd"
285:                            + "+DvKECrO5+yoPRx3AJ91DhCMme6uMrQorKSDYxHlgc7iT7ACAAA=");
286:
287:            char[] pass = { 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l',
288:                    'd' };
289:
290:            /**
291:             * Generated signature test
292:             * 
293:             * @param sKey
294:             * @param pgpPrivKey
295:             */
296:            public void generateTest(PGPSecretKeyRing sKey,
297:                    PGPPublicKey pgpPubKey, PGPPrivateKey pgpPrivKey)
298:                    throws Exception {
299:                String data = "hello world!";
300:                ByteArrayOutputStream bOut = new ByteArrayOutputStream();
301:                ByteArrayInputStream testIn = new ByteArrayInputStream(data
302:                        .getBytes());
303:                PGPSignatureGenerator sGen = new PGPSignatureGenerator(
304:                        PublicKeyAlgorithmTags.DSA, HashAlgorithmTags.SHA1,
305:                        "BC");
306:
307:                sGen.initSign(PGPSignature.BINARY_DOCUMENT, pgpPrivKey);
308:
309:                PGPSignatureSubpacketGenerator spGen = new PGPSignatureSubpacketGenerator();
310:
311:                Iterator it = sKey.getSecretKey().getPublicKey().getUserIDs();
312:                String primaryUserID = (String) it.next();
313:
314:                spGen.setSignerUserID(true, primaryUserID);
315:
316:                sGen.setHashedSubpackets(spGen.generate());
317:
318:                PGPCompressedDataGenerator cGen = new PGPCompressedDataGenerator(
319:                        PGPCompressedData.ZIP);
320:
321:                BCPGOutputStream bcOut = new BCPGOutputStream(cGen
322:                        .open(new UncloseableOutputStream(bOut)));
323:
324:                sGen.generateOnePassVersion(false).encode(bcOut);
325:
326:                PGPLiteralDataGenerator lGen = new PGPLiteralDataGenerator();
327:
328:                Date testDate = new Date(
329:                        (System.currentTimeMillis() / 1000) * 1000);
330:                OutputStream lOut = lGen.open(
331:                        new UncloseableOutputStream(bcOut),
332:                        PGPLiteralData.BINARY, "_CONSOLE",
333:                        data.getBytes().length, testDate);
334:
335:                int ch;
336:                while ((ch = testIn.read()) >= 0) {
337:                    lOut.write(ch);
338:                    sGen.update((byte) ch);
339:                }
340:
341:                lGen.close();
342:
343:                sGen.generate().encode(bcOut);
344:
345:                cGen.close();
346:
347:                PGPObjectFactory pgpFact = new PGPObjectFactory(bOut
348:                        .toByteArray());
349:                PGPCompressedData c1 = (PGPCompressedData) pgpFact.nextObject();
350:
351:                pgpFact = new PGPObjectFactory(c1.getDataStream());
352:
353:                PGPOnePassSignatureList p1 = (PGPOnePassSignatureList) pgpFact
354:                        .nextObject();
355:                PGPOnePassSignature ops = p1.get(0);
356:
357:                PGPLiteralData p2 = (PGPLiteralData) pgpFact.nextObject();
358:                if (!p2.getModificationTime().equals(testDate)) {
359:                    fail("Modification time not preserved");
360:                }
361:
362:                InputStream dIn = p2.getInputStream();
363:
364:                ops.initVerify(pgpPubKey, "BC");
365:
366:                while ((ch = dIn.read()) >= 0) {
367:                    ops.update((byte) ch);
368:                }
369:
370:                PGPSignatureList p3 = (PGPSignatureList) pgpFact.nextObject();
371:
372:                if (!ops.verify(p3.get(0))) {
373:                    fail("Failed generated signature check");
374:                }
375:            }
376:
377:            public void performTest() throws Exception {
378:                String file = null;
379:                KeyFactory fact = KeyFactory.getInstance("DSA", "BC");
380:                PGPPublicKey pubKey = null;
381:                PrivateKey privKey = null;
382:
383:                PGPUtil.setDefaultProvider("BC");
384:
385:                //
386:                // Read the public key
387:                //
388:                PGPPublicKeyRing pgpPub = new PGPPublicKeyRing(testPubKey);
389:
390:                pubKey = pgpPub.getPublicKey();
391:
392:                //
393:                // Read the private key
394:                //
395:                PGPSecretKeyRing sKey = new PGPSecretKeyRing(testPrivKey);
396:                PGPPrivateKey pgpPrivKey = sKey.getSecretKey()
397:                        .extractPrivateKey(pass, "BC");
398:
399:                //
400:                // test signature message
401:                //
402:                PGPObjectFactory pgpFact = new PGPObjectFactory(sig1);
403:
404:                PGPCompressedData c1 = (PGPCompressedData) pgpFact.nextObject();
405:
406:                pgpFact = new PGPObjectFactory(c1.getDataStream());
407:
408:                PGPOnePassSignatureList p1 = (PGPOnePassSignatureList) pgpFact
409:                        .nextObject();
410:
411:                PGPOnePassSignature ops = p1.get(0);
412:
413:                PGPLiteralData p2 = (PGPLiteralData) pgpFact.nextObject();
414:
415:                InputStream dIn = p2.getInputStream();
416:                int ch;
417:
418:                ops.initVerify(pubKey, "BC");
419:
420:                while ((ch = dIn.read()) >= 0) {
421:                    ops.update((byte) ch);
422:                }
423:
424:                PGPSignatureList p3 = (PGPSignatureList) pgpFact.nextObject();
425:
426:                if (!ops.verify(p3.get(0))) {
427:                    fail("Failed signature check");
428:                }
429:
430:                //
431:                // signature generation
432:                //
433:                generateTest(sKey, pubKey, pgpPrivKey);
434:
435:                //
436:                // signature generation - canonical text
437:                //
438:                String data = "hello world!";
439:                ByteArrayOutputStream bOut = new ByteArrayOutputStream();
440:                ByteArrayInputStream testIn = new ByteArrayInputStream(data
441:                        .getBytes());
442:                PGPSignatureGenerator sGen = new PGPSignatureGenerator(
443:                        PGPPublicKey.DSA, PGPUtil.SHA1, "BC");
444:
445:                sGen.initSign(PGPSignature.CANONICAL_TEXT_DOCUMENT, pgpPrivKey);
446:
447:                PGPCompressedDataGenerator cGen = new PGPCompressedDataGenerator(
448:                        PGPCompressedData.ZIP);
449:
450:                BCPGOutputStream bcOut = new BCPGOutputStream(cGen
451:                        .open(new UncloseableOutputStream(bOut)));
452:
453:                sGen.generateOnePassVersion(false).encode(bcOut);
454:
455:                PGPLiteralDataGenerator lGen = new PGPLiteralDataGenerator();
456:                Date testDate = new Date(
457:                        (System.currentTimeMillis() / 1000) * 1000);
458:                OutputStream lOut = lGen.open(
459:                        new UncloseableOutputStream(bcOut),
460:                        PGPLiteralData.TEXT, "_CONSOLE",
461:                        data.getBytes().length, testDate);
462:
463:                while ((ch = testIn.read()) >= 0) {
464:                    lOut.write(ch);
465:                    sGen.update((byte) ch);
466:                }
467:
468:                sGen.generate().encode(bcOut);
469:
470:                lGen.close();
471:
472:                cGen.close();
473:
474:                //
475:                // verify generated signature - canconical text
476:                //
477:                pgpFact = new PGPObjectFactory(bOut.toByteArray());
478:
479:                c1 = (PGPCompressedData) pgpFact.nextObject();
480:
481:                pgpFact = new PGPObjectFactory(c1.getDataStream());
482:
483:                p1 = (PGPOnePassSignatureList) pgpFact.nextObject();
484:
485:                ops = p1.get(0);
486:
487:                p2 = (PGPLiteralData) pgpFact.nextObject();
488:                if (!p2.getModificationTime().equals(testDate)) {
489:                    fail("Modification time not preserved");
490:                }
491:
492:                dIn = p2.getInputStream();
493:
494:                ops.initVerify(pubKey, "BC");
495:
496:                while ((ch = dIn.read()) >= 0) {
497:                    ops.update((byte) ch);
498:                }
499:
500:                p3 = (PGPSignatureList) pgpFact.nextObject();
501:
502:                if (!ops.verify(p3.get(0))) {
503:                    fail("Failed generated signature check");
504:                }
505:
506:                //
507:                // Read the public key with user attributes
508:                //
509:                pgpPub = new PGPPublicKeyRing(testPubWithUserAttr);
510:
511:                pubKey = pgpPub.getPublicKey();
512:
513:                Iterator it = pubKey.getUserAttributes();
514:                int count = 0;
515:                while (it.hasNext()) {
516:                    PGPUserAttributeSubpacketVector attributes = (PGPUserAttributeSubpacketVector) it
517:                            .next();
518:
519:                    Iterator sigs = pubKey
520:                            .getSignaturesForUserAttribute(attributes);
521:                    int sigCount = 0;
522:                    while (sigs.hasNext()) {
523:                        sigs.next();
524:
525:                        sigCount++;
526:                    }
527:
528:                    if (sigCount != 1) {
529:                        fail("Failed user attributes signature check");
530:                    }
531:                    count++;
532:                }
533:
534:                if (count != 1) {
535:                    fail("Failed user attributes check");
536:                }
537:
538:                byte[] pgpPubBytes = pgpPub.getEncoded();
539:
540:                pgpPub = new PGPPublicKeyRing(pgpPubBytes);
541:
542:                pubKey = pgpPub.getPublicKey();
543:
544:                it = pubKey.getUserAttributes();
545:                count = 0;
546:                while (it.hasNext()) {
547:                    it.next();
548:                    count++;
549:                }
550:
551:                if (count != 1) {
552:                    fail("Failed user attributes reread");
553:                }
554:
555:                //
556:                // reading test extra data - key with edge condition for DSA key password.
557:                //
558:                char[] passPhrase = { '0', '1', '2', '3', '4', '5', '6', '7',
559:                        '8', '9' };
560:
561:                sKey = new PGPSecretKeyRing(testPrivKey2);
562:                pgpPrivKey = sKey.getSecretKey().extractPrivateKey(passPhrase,
563:                        "BC");
564:
565:                byte[] bytes = pgpPrivKey.getKey().getEncoded();
566:
567:                //
568:                // reading test - aes256 encrypted passphrase.
569:                //
570:                sKey = new PGPSecretKeyRing(aesSecretKey);
571:                pgpPrivKey = sKey.getSecretKey().extractPrivateKey(pass, "BC");
572:
573:                bytes = pgpPrivKey.getKey().getEncoded();
574:
575:                //
576:                // reading test - twofish encrypted passphrase.
577:                //
578:                sKey = new PGPSecretKeyRing(twofishSecretKey);
579:                pgpPrivKey = sKey.getSecretKey().extractPrivateKey(pass, "BC");
580:
581:                bytes = pgpPrivKey.getKey().getEncoded();
582:
583:                //
584:                // use of PGPKeyPair
585:                //
586:                KeyPairGenerator kpg = KeyPairGenerator
587:                        .getInstance("DSA", "BC");
588:
589:                kpg.initialize(512);
590:
591:                KeyPair kp = kpg.generateKeyPair();
592:
593:                PGPKeyPair pgpKp = new PGPKeyPair(PGPPublicKey.DSA, kp
594:                        .getPublic(), kp.getPrivate(), new Date(), "BC");
595:
596:                PGPPublicKey k1 = pgpKp.getPublicKey();
597:
598:                PGPPrivateKey k2 = pgpKp.getPrivateKey();
599:            }
600:
601:            public String getName() {
602:                return "PGPDSATest";
603:            }
604:
605:            public static void main(String[] args) {
606:                Security.addProvider(new BouncyCastleProvider());
607:
608:                runTest(new PGPSignatureTest());
609:            }
610:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.