Source Code Cross Referenced for MD2.java in  » Portal » Open-Portal » com » sun » portal » ksecurity » 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 » Portal » Open Portal » com.sun.portal.ksecurity 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)MD2.java	1.3 02/07/24 @(#)
003:         *
004:         * Copyright (c) 2001 Sun Microsystems, Inc.  All rights reserved.
005:         * PROPRIETARY/CONFIDENTIAL
006:         * Use is subject to license terms.
007:         */
008:
009:        package com.sun.portal.ksecurity;
010:
011:        /**
012:         * Implements the MD2 hashing algorithm as described in IETF RFC 1321
013:         * (see http://www.ietf.org/rfc/rfc1321.txt)
014:         */
015:        final class MD2 extends MessageDigest {
016:            /*
017:             * The compute intensive operations are implemented in C
018:             * based on the OpenSSL MD2 code (from pilotSSLeay). Here we
019:             * replicate the state the C code needs.
020:             */
021:
022:            // Internal context
023:            private int[] num = new int[1];
024:            private byte[] data = new byte[16];
025:            private int[] cksm = new int[16];
026:            private int[] state = new int[16];
027:
028:            private byte type; // message digest algorithm
029:            private byte len; // length of hash in bytes
030:
031:            MD2() {
032:                type = ALG_MD2;
033:                len = 16;
034:                reset();
035:            }
036:
037:            public byte getAlgorithm() {
038:                return type;
039:            }
040:
041:            public byte getLength() {
042:                return len;
043:            }
044:
045:            /* MD2 initialization. Begins an MD2 operation, writing a new context */
046:            public void reset() {
047:                num[0] = 0;
048:
049:                for (int i = 0; i < 16; i++) {
050:                    data[i] = (byte) 0;
051:                    cksm[i] = 0;
052:                    state[i] = 0;
053:                }
054:            }
055:
056:            /*
057:             * MD2 block update operation. Continues an MD2 message-digest
058:             * operation, processing another message block, and updating internal
059:             * context.
060:             */
061:            public void update(byte[] inBuf, int inOff, int inLen) {
062:                if (inLen == 0)
063:                    return;
064:
065:                // check parameters to prevent VM from crashing
066:                int test = inBuf[inOff] + inBuf[inLen - 1]
067:                        + inBuf[inOff + inLen - 1];
068:
069:                nativeUpdate(inBuf, inOff, inLen, state, num, cksm, data);
070:            }
071:
072:            private static native void nativeUpdate(byte[] inBuf, int inOff,
073:                    int inLen, int[] state, int[] num, int[] cksm, byte[] data);
074:
075:            public short doFinal(byte[] inBuf, int inOff, int inLen,
076:                    byte[] outBuf, int outOff) {
077:                // check the parameters to prevent a VM crash
078:                int test = outBuf[outOff] + outBuf[outOff + 15];
079:                if (inLen != 0) {
080:                    test = inBuf[inOff] + inBuf[inLen - 1]
081:                            + inBuf[inOff + inLen - 1];
082:                }
083:
084:                nativeFinal(inBuf, inOff, inLen, outBuf, outOff, state, num,
085:                        cksm, data);
086:                return (short) 16;
087:            }
088:
089:            private static native void nativeFinal(byte[] inBuf, int inOff,
090:                    int inLen, byte[] outBuf, int outOff, int[] state,
091:                    int[] num, int[] cksm, byte[] data);
092:
093:            public Object clone() {
094:                MD2 cpy = new MD2();
095:
096:                System.arraycopy(this .state, 0, cpy.state, 0, 16);
097:                System.arraycopy(this .num, 0, cpy.num, 0, 1);
098:                System.arraycopy(this .cksm, 0, cpy.cksm, 0, 16);
099:                System.arraycopy(this .data, 0, cpy.data, 0, 16);
100:                cpy.type = this.type;
101:                cpy.len = this.len;
102:                return cpy;
103:            }
104:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.