Source Code Cross Referenced for MDGoldenData.java in  » Apache-Harmony-Java-SE » org-package » org » apache » harmony » security » tests » support » 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 » Apache Harmony Java SE » org package » org.apache.harmony.security.tests.support 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:        /**
018:         * @author Vladimir N. Molotkov
019:         * @version $Revision$
020:         */package org.apache.harmony.security.tests.support;
021:
022:        import java.util.HashMap;
023:
024:        /**
025:         * Golden data for Message Digest related tests.<br>
026:         * Encapsulates the following data:<br>
027:         * - reference message<br>
028:         * - reference message digests calculated using
029:         *   BEA JRockit j2sdk1.4.2_04 (http://www.bea.com)
030:         *   for various MD algorithms: 
031:         *   SHA-1, SHA-256, SHA-384, SHA-512, MD-5.
032:         * Standard algorithm names are defined in 
033:         * "JavaTM Cryptography Architecture API Specification & Reference"
034:         *   
035:         */
036:        public class MDGoldenData {
037:            // The length of test message
038:            private static final int MY_MESSAGE_LEN = 1024;
039:            // Test message for digest computations
040:            private static final byte[] myMessage = new byte[MY_MESSAGE_LEN];
041:            // Reference digests for various algorithms calculated
042:            // for <code>myMessage</code>
043:            private static final HashMap goldenData = new HashMap();
044:
045:            static {
046:                // fill myMessage
047:                for (int i = 0; i < myMessage.length; i++) {
048:                    myMessage[i] = (byte) i;
049:                }
050:                // fill goldenData
051:                // digest updated with myMessage bytes
052:                goldenData.put("SHA-1", new byte[] { (byte) 0x5b, (byte) 0x00,
053:                        (byte) 0x66, (byte) 0x9c, (byte) 0x48, (byte) 0x0d,
054:                        (byte) 0x5c, (byte) 0xff, (byte) 0xbd, (byte) 0xfa,
055:                        (byte) 0x8b, (byte) 0xdb, (byte) 0xa9, (byte) 0x95,
056:                        (byte) 0x61, (byte) 0x16, (byte) 0x0f, (byte) 0x2d,
057:                        (byte) 0x1b, (byte) 0x77 });
058:                // digest without updates at all;
059:                // use MD algorithm name + "_NU" if not updated MD value is needed
060:                goldenData.put("SHA-1_NU", new byte[] { (byte) 0xda,
061:                        (byte) 0x39, (byte) 0xa3, (byte) 0xee, (byte) 0x5e,
062:                        (byte) 0x6b, (byte) 0x4b, (byte) 0x0d, (byte) 0x32,
063:                        (byte) 0x55, (byte) 0xbf, (byte) 0xef, (byte) 0x95,
064:                        (byte) 0x60, (byte) 0x18, (byte) 0x90, (byte) 0xaf,
065:                        (byte) 0xd8, (byte) 0x07, (byte) 0x09 });
066:
067:                goldenData.put("SHA", goldenData.get("SHA-1"));
068:                goldenData.put("SHA_NU", goldenData.get("SHA-1_NU"));
069:
070:                goldenData.put("SHA1", goldenData.get("SHA-1"));
071:                goldenData.put("SHA1_NU", goldenData.get("SHA-1_NU"));
072:
073:                goldenData.put("SHA-256", new byte[] { (byte) 0x78,
074:                        (byte) 0x5b, (byte) 0x07, (byte) 0x51, (byte) 0xfc,
075:                        (byte) 0x2c, (byte) 0x53, (byte) 0xdc, (byte) 0x14,
076:                        (byte) 0xa4, (byte) 0xce, (byte) 0x3d, (byte) 0x80,
077:                        (byte) 0x0e, (byte) 0x69, (byte) 0xef, (byte) 0x9c,
078:                        (byte) 0xe1, (byte) 0x00, (byte) 0x9e, (byte) 0xb3,
079:                        (byte) 0x27, (byte) 0xcc, (byte) 0xf4, (byte) 0x58,
080:                        (byte) 0xaf, (byte) 0xe0, (byte) 0x9c, (byte) 0x24,
081:                        (byte) 0x2c, (byte) 0x26, (byte) 0xc9 });
082:                goldenData.put("SHA-256_NU", new byte[] { (byte) 0xe3,
083:                        (byte) 0xb0, (byte) 0xc4, (byte) 0x42, (byte) 0x98,
084:                        (byte) 0xfc, (byte) 0x1c, (byte) 0x14, (byte) 0x9a,
085:                        (byte) 0xfb, (byte) 0xf4, (byte) 0xc8, (byte) 0x99,
086:                        (byte) 0x6f, (byte) 0xb9, (byte) 0x24, (byte) 0x27,
087:                        (byte) 0xae, (byte) 0x41, (byte) 0xe4, (byte) 0x64,
088:                        (byte) 0x9b, (byte) 0x93, (byte) 0x4c, (byte) 0xa4,
089:                        (byte) 0x95, (byte) 0x99, (byte) 0x1b, (byte) 0x78,
090:                        (byte) 0x52, (byte) 0xb8, (byte) 0x55 });
091:                goldenData.put("SHA-384", new byte[] { (byte) 0x55,
092:                        (byte) 0xfd, (byte) 0x17, (byte) 0xee, (byte) 0xb1,
093:                        (byte) 0x61, (byte) 0x1f, (byte) 0x91, (byte) 0x93,
094:                        (byte) 0xf6, (byte) 0xac, (byte) 0x60, (byte) 0x02,
095:                        (byte) 0x38, (byte) 0xce, (byte) 0x63, (byte) 0xaa,
096:                        (byte) 0x29, (byte) 0x8c, (byte) 0x2e, (byte) 0x33,
097:                        (byte) 0x2f, (byte) 0x04, (byte) 0x2b, (byte) 0x80,
098:                        (byte) 0xc8, (byte) 0xf6, (byte) 0x91, (byte) 0xf8,
099:                        (byte) 0x00, (byte) 0xe4, (byte) 0xc7, (byte) 0x50,
100:                        (byte) 0x5a, (byte) 0xf2, (byte) 0x0c, (byte) 0x1a,
101:                        (byte) 0x86, (byte) 0xa3, (byte) 0x1f, (byte) 0x08,
102:                        (byte) 0x50, (byte) 0x45, (byte) 0x87, (byte) 0x39,
103:                        (byte) 0x5f, (byte) 0x08, (byte) 0x1f });
104:                goldenData.put("SHA-384_NU", new byte[] { (byte) 0x38,
105:                        (byte) 0xb0, (byte) 0x60, (byte) 0xa7, (byte) 0x51,
106:                        (byte) 0xac, (byte) 0x96, (byte) 0x38, (byte) 0x4c,
107:                        (byte) 0xd9, (byte) 0x32, (byte) 0x7e, (byte) 0xb1,
108:                        (byte) 0xb1, (byte) 0xe3, (byte) 0x6a, (byte) 0x21,
109:                        (byte) 0xfd, (byte) 0xb7, (byte) 0x11, (byte) 0x14,
110:                        (byte) 0xbe, (byte) 0x07, (byte) 0x43, (byte) 0x4c,
111:                        (byte) 0x0c, (byte) 0xc7, (byte) 0xbf, (byte) 0x63,
112:                        (byte) 0xf6, (byte) 0xe1, (byte) 0xda, (byte) 0x27,
113:                        (byte) 0x4e, (byte) 0xde, (byte) 0xbf, (byte) 0xe7,
114:                        (byte) 0x6f, (byte) 0x65, (byte) 0xfb, (byte) 0xd5,
115:                        (byte) 0x1a, (byte) 0xd2, (byte) 0xf1, (byte) 0x48,
116:                        (byte) 0x98, (byte) 0xb9, (byte) 0x5b });
117:                goldenData.put("SHA-512", new byte[] { (byte) 0x37,
118:                        (byte) 0xf6, (byte) 0x52, (byte) 0xbe, (byte) 0x86,
119:                        (byte) 0x7f, (byte) 0x28, (byte) 0xed, (byte) 0x03,
120:                        (byte) 0x32, (byte) 0x69, (byte) 0xcb, (byte) 0xba,
121:                        (byte) 0x20, (byte) 0x1a, (byte) 0xf2, (byte) 0x11,
122:                        (byte) 0x2c, (byte) 0x2b, (byte) 0x3f, (byte) 0xd3,
123:                        (byte) 0x34, (byte) 0xa8, (byte) 0x9f, (byte) 0xd2,
124:                        (byte) 0xf7, (byte) 0x57, (byte) 0x93, (byte) 0x8d,
125:                        (byte) 0xde, (byte) 0xe8, (byte) 0x15, (byte) 0x78,
126:                        (byte) 0x7c, (byte) 0xc6, (byte) 0x1d, (byte) 0x6e,
127:                        (byte) 0x24, (byte) 0xa8, (byte) 0xa3, (byte) 0x33,
128:                        (byte) 0x40, (byte) 0xd0, (byte) 0xf7, (byte) 0xe8,
129:                        (byte) 0x6f, (byte) 0xfc, (byte) 0x05, (byte) 0x88,
130:                        (byte) 0x16, (byte) 0xb8, (byte) 0x85, (byte) 0x30,
131:                        (byte) 0x76, (byte) 0x6b, (byte) 0xa6, (byte) 0xe2,
132:                        (byte) 0x31, (byte) 0x62, (byte) 0x0a, (byte) 0x13,
133:                        (byte) 0x0b, (byte) 0x56, (byte) 0x6c });
134:                goldenData.put("SHA-512_NU", new byte[] { (byte) 0xcf,
135:                        (byte) 0x83, (byte) 0xe1, (byte) 0x35, (byte) 0x7e,
136:                        (byte) 0xef, (byte) 0xb8, (byte) 0xbd, (byte) 0xf1,
137:                        (byte) 0x54, (byte) 0x28, (byte) 0x50, (byte) 0xd6,
138:                        (byte) 0x6d, (byte) 0x80, (byte) 0x07, (byte) 0xd6,
139:                        (byte) 0x20, (byte) 0xe4, (byte) 0x05, (byte) 0x0b,
140:                        (byte) 0x57, (byte) 0x15, (byte) 0xdc, (byte) 0x83,
141:                        (byte) 0xf4, (byte) 0xa9, (byte) 0x21, (byte) 0xd3,
142:                        (byte) 0x6c, (byte) 0xe9, (byte) 0xce, (byte) 0x47,
143:                        (byte) 0xd0, (byte) 0xd1, (byte) 0x3c, (byte) 0x5d,
144:                        (byte) 0x85, (byte) 0xf2, (byte) 0xb0, (byte) 0xff,
145:                        (byte) 0x83, (byte) 0x18, (byte) 0xd2, (byte) 0x87,
146:                        (byte) 0x7e, (byte) 0xec, (byte) 0x2f, (byte) 0x63,
147:                        (byte) 0xb9, (byte) 0x31, (byte) 0xbd, (byte) 0x47,
148:                        (byte) 0x41, (byte) 0x7a, (byte) 0x81, (byte) 0xa5,
149:                        (byte) 0x38, (byte) 0x32, (byte) 0x7a, (byte) 0xf9,
150:                        (byte) 0x27, (byte) 0xda, (byte) 0x3e });
151:                goldenData.put("MD5", new byte[] { (byte) 0xb2, (byte) 0xea,
152:                        (byte) 0x9f, (byte) 0x7f, (byte) 0xce, (byte) 0xa8,
153:                        (byte) 0x31, (byte) 0xa4, (byte) 0xa6, (byte) 0x3b,
154:                        (byte) 0x21, (byte) 0x3f, (byte) 0x41, (byte) 0xa8,
155:                        (byte) 0x85, (byte) 0x5b });
156:                goldenData.put("MD5_NU", new byte[] { (byte) 0xd4, (byte) 0x1d,
157:                        (byte) 0x8c, (byte) 0xd9, (byte) 0x8f, (byte) 0x00,
158:                        (byte) 0xb2, (byte) 0x04, (byte) 0xe9, (byte) 0x80,
159:                        (byte) 0x09, (byte) 0x98, (byte) 0xec, (byte) 0xf8,
160:                        (byte) 0x42, (byte) 0x7e });
161:            }
162:
163:            // No need to instantiate
164:            private MDGoldenData() {
165:            }
166:
167:            /**
168:             * Returns reference message
169:             *
170:             * @return reference message
171:             */
172:            public static byte[] getMessage() {
173:                return myMessage.clone();
174:            }
175:
176:            /**
177:             * Returns digest golden data
178:             *
179:             * @param key
180:             *  MD algorithm name or MD algorithm name + "_NU" if
181:             *  not updated MD value requested  
182:             * @return
183:             *  reference digest for specified MD algorithm name
184:             */
185:            public static byte[] getDigest(String key) {
186:                return ((byte[]) goldenData.get(key)).clone();
187:            }
188:
189:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.