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


001:        package org.bouncycastle.crypto;
002:
003:        /**
004:         * super class for all Password Based Encryption (PBE) parameter generator classes.
005:         */
006:        public abstract class PBEParametersGenerator {
007:            protected byte[] password;
008:            protected byte[] salt;
009:            protected int iterationCount;
010:
011:            /**
012:             * base constructor.
013:             */
014:            protected PBEParametersGenerator() {
015:            }
016:
017:            /**
018:             * initialise the PBE generator.
019:             *
020:             * @param password the password converted into bytes (see below).
021:             * @param salt the salt to be mixed with the password.
022:             * @param iterationCount the number of iterations the "mixing" function
023:             * is to be applied for.
024:             */
025:            public void init(byte[] password, byte[] salt, int iterationCount) {
026:                this .password = password;
027:                this .salt = salt;
028:                this .iterationCount = iterationCount;
029:            }
030:
031:            /**
032:             * return the password byte array.
033:             *
034:             * @return the password byte array.
035:             */
036:            public byte[] getPassword() {
037:                return password;
038:            }
039:
040:            /**
041:             * return the salt byte array.
042:             *
043:             * @return the salt byte array.
044:             */
045:            public byte[] getSalt() {
046:                return salt;
047:            }
048:
049:            /**
050:             * return the iteration count.
051:             *
052:             * @return the iteration count.
053:             */
054:            public int getIterationCount() {
055:                return iterationCount;
056:            }
057:
058:            /**
059:             * generate derived parameters for a key of length keySize.
060:             *
061:             * @param keySize the length, in bits, of the key required.
062:             * @return a parameters object representing a key.
063:             */
064:            public abstract CipherParameters generateDerivedParameters(
065:                    int keySize);
066:
067:            /**
068:             * generate derived parameters for a key of length keySize, and
069:             * an initialisation vector (IV) of length ivSize.
070:             *
071:             * @param keySize the length, in bits, of the key required.
072:             * @param ivSize the length, in bits, of the iv required.
073:             * @return a parameters object representing a key and an IV.
074:             */
075:            public abstract CipherParameters generateDerivedParameters(
076:                    int keySize, int ivSize);
077:
078:            /**
079:             * generate derived parameters for a key of length keySize, specifically
080:             * for use with a MAC.
081:             *
082:             * @param keySize the length, in bits, of the key required.
083:             * @return a parameters object representing a key.
084:             */
085:            public abstract CipherParameters generateDerivedMacParameters(
086:                    int keySize);
087:
088:            /**
089:             * converts a password to a byte array according to the scheme in
090:             * PKCS5 (ascii, no padding)
091:             *
092:             * @param password a character array reqpresenting the password.
093:             * @return a byte array representing the password.
094:             */
095:            public static byte[] PKCS5PasswordToBytes(char[] password) {
096:                byte[] bytes = new byte[password.length];
097:
098:                for (int i = 0; i != bytes.length; i++) {
099:                    bytes[i] = (byte) password[i];
100:                }
101:
102:                return bytes;
103:            }
104:
105:            /**
106:             * converts a password to a byte array according to the scheme in
107:             * PKCS12 (unicode, big endian, 2 zero pad bytes at the end).
108:             *
109:             * @param password a character array representing the password.
110:             * @return a byte array representing the password.
111:             */
112:            public static byte[] PKCS12PasswordToBytes(char[] password) {
113:                if (password.length > 0) {
114:                    // +1 for extra 2 pad bytes.
115:                    byte[] bytes = new byte[(password.length + 1) * 2];
116:
117:                    for (int i = 0; i != password.length; i++) {
118:                        bytes[i * 2] = (byte) (password[i] >>> 8);
119:                        bytes[i * 2 + 1] = (byte) password[i];
120:                    }
121:
122:                    return bytes;
123:                } else {
124:                    return new byte[0];
125:                }
126:            }
127:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.