directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From plusplusjia...@apache.org
Subject [1/2] directory-kerby git commit: Fix javadoc errors of kerb-crypto module.
Date Mon, 24 Aug 2015 05:31:11 GMT
Repository: directory-kerby
Updated Branches:
  refs/heads/master 1ac2d0a52 -> 024d572a9


Fix javadoc errors of kerb-crypto module.


Project: http://git-wip-us.apache.org/repos/asf/directory-kerby/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-kerby/commit/ec0f46b1
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerby/tree/ec0f46b1
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerby/diff/ec0f46b1

Branch: refs/heads/master
Commit: ec0f46b1b8603b80543aff359ac09dd524f18235
Parents: 4a60163
Author: plusplusjiajia <jiajia.li@intel.com>
Authored: Mon Aug 24 13:35:30 2015 +0800
Committer: plusplusjiajia <jiajia.li@intel.com>
Committed: Mon Aug 24 13:35:30 2015 +0800

----------------------------------------------------------------------
 .../kerberos/kerb/crypto/EncryptionHandler.java | 115 ++++++++++++++++++-
 .../kerberos/kerb/crypto/fast/FastUtil.java     |  18 ++-
 .../kerb/crypto/key/AbstractKeyMaker.java       |   5 +-
 .../kerberos/kerb/crypto/key/DesKeyMaker.java   |   9 +-
 .../kerberos/kerb/crypto/random/JavaRandom.java |   3 +-
 .../kerb/crypto/random/RandomProvider.java      |   4 +-
 .../kerberos/kerb/crypto/util/Camellia.java     |   8 ++
 .../kerby/kerberos/kerb/crypto/util/Des.java    |   3 +
 .../kerby/kerberos/kerb/crypto/util/Nfold.java  |   5 +-
 9 files changed, 151 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ec0f46b1/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/EncryptionHandler.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/EncryptionHandler.java
b/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/EncryptionHandler.java
index bf6408f..7c811ef 100644
--- a/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/EncryptionHandler.java
+++ b/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/EncryptionHandler.java
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
  *  under the License. 
- *  
+ *
  */
 package org.apache.kerby.kerberos.kerb.crypto;
 
@@ -52,34 +52,72 @@ public class EncryptionHandler {
     static {
         try {
             isAES256Enabled = Cipher.getMaxAllowedKeyLength("AES") >= 256;
-        } catch (Exception e) { //NOPMD
+        } catch (Exception e) {
             System.err.println(e);
         }
     }
 
+    /**
+     * @return true if aes256 is enabled
+     */
     public static boolean isAES256Enabled() {
         return isAES256Enabled;
     }
 
+    /**
+     * Get the encryption type.
+     * @param eType The encryption type string.
+     * @return The EncryptionType
+     * @throws KrbException e
+     */
     public static EncryptionType getEncryptionType(String eType) throws KrbException {
         EncryptionType result = EncryptionType.fromName(eType);
         return result;
     }
 
+    /**
+     * Get the encryption handler.
+     *
+     * @param eType The encryption type string
+     * @return The EncTypeHandler
+     * @throws KrbException e
+     */
     public static EncTypeHandler getEncHandler(String eType) throws KrbException {
         EncryptionType result = EncryptionType.fromName(eType);
         return getEncHandler(result);
     }
 
+    /**
+     * Get the encryption handler.
+     *
+     * @param eType The encryption type int
+     * @return The EncTypeHandler
+     * @throws KrbException e
+     */
     public static EncTypeHandler getEncHandler(int eType) throws KrbException {
         EncryptionType eTypeEnum = EncryptionType.fromValue(eType);
         return getEncHandler(eTypeEnum);
     }
 
+    /**
+     * Get the encryption handler.
+     *
+     * @param eType The encryption type
+     * @return The EncTypeHandler
+     * @throws KrbException e
+     */
     public static EncTypeHandler getEncHandler(EncryptionType eType) throws KrbException
{
         return getEncHandler(eType, false);
     }
 
+    /**
+     * Get the encryption handler.
+     *
+     * @param eType The encryption type
+     * @param check true if check
+     * @return The EncTypeHandler
+     * @throws KrbException e
+     */
     private static EncTypeHandler getEncHandler(EncryptionType eType,
                                                 boolean check) throws KrbException {
         EncTypeHandler encHandler = null;
@@ -149,6 +187,15 @@ public class EncryptionHandler {
         return encHandler;
     }
 
+    /**
+     * Encrypt with the encryption key and key usage.
+     *
+     * @param plainText The plain test
+     * @param key The encryption key
+     * @param usage The key usage
+     * @return The encrypted data
+     * @throws KrbException e
+     */
     public static EncryptedData encrypt(byte[] plainText, EncryptionKey key,
                                         KeyUsage usage) throws KrbException {
         EncTypeHandler handler = getEncHandler(key.getKeyType());
@@ -162,6 +209,15 @@ public class EncryptionHandler {
         return ed;
     }
 
+    /**
+     * Decrypt with the encryption key and key usage.
+     *
+     * @param data The encrypted data
+     * @param key The encryption key
+     * @param usage The key usage
+     * @return The decrypted data
+     * @throws KrbException e
+     */
     public static byte[] decrypt(byte[] data, EncryptionKey key,
                                  KeyUsage usage) throws KrbException {
         EncTypeHandler handler = getEncHandler(key.getKeyType());
@@ -170,6 +226,15 @@ public class EncryptionHandler {
         return plainData;
     }
 
+    /**
+     * Decrypt with the encryption key and key usage.
+     *
+     * @param data  The encrypted data
+     * @param key   The encryption key
+     * @param usage The key usage
+     * @return The decrypted data
+     * @throws KrbException e
+     */
     public static byte[] decrypt(EncryptedData data, EncryptionKey key,
                                  KeyUsage usage) throws KrbException {
         EncTypeHandler handler = getEncHandler(key.getKeyType());
@@ -179,6 +244,12 @@ public class EncryptionHandler {
         return plainData;
     }
 
+    /**
+     * Return true if the the encryption handler is implemented.
+     *
+     * @param eType   The encryption type
+     * @return true if the encryption handler is implemented
+     */
     public static boolean isImplemented(EncryptionType eType) {
         EncTypeHandler handler = null;
         try {
@@ -189,6 +260,15 @@ public class EncryptionHandler {
         return  handler != null;
     }
 
+    /**
+     * String to key.
+     *
+     * @param principalName  The principal name
+     * @param passPhrase   The pass phrase
+     * @param eType The encryption type
+     * @return The encryption key
+     * @throws KrbException e
+     */
     public static EncryptionKey string2Key(String principalName,
           String passPhrase, EncryptionType eType) throws KrbException {
         PrincipalName principal = new PrincipalName(principalName);
@@ -196,6 +276,16 @@ public class EncryptionHandler {
                 PrincipalName.makeSalt(principal), null, eType);
     }
 
+    /**
+     * String to key.
+     *
+     * @param string The string
+     * @param salt The salt
+     * @param s2kparams The params
+     * @param eType The encryption type
+     * @return The encryption key
+     * @throws KrbException e
+     */
     public static EncryptionKey string2Key(String string, String salt,
                    byte[] s2kparams, EncryptionType eType) throws KrbException {
         EncTypeHandler handler = getEncHandler(eType);
@@ -203,6 +293,13 @@ public class EncryptionHandler {
         return new EncryptionKey(eType, keyBytes);
     }
 
+    /**
+     * Random to key.
+     *
+     * @param eType The encryption type
+     * @return The encryption key
+     * @throws KrbException e
+     */
     public static EncryptionKey random2Key(EncryptionType eType) throws KrbException {
         EncTypeHandler handler = getEncHandler(eType);
 
@@ -212,6 +309,14 @@ public class EncryptionHandler {
         return encKey;
     }
 
+    /**
+     * Random to key.
+     *
+     * @param eType The encryption type
+     * @param randomBytes The random bytes
+     * @return The encryption key
+     * @throws KrbException e
+     */
     public static EncryptionKey random2Key(EncryptionType eType, byte[] randomBytes) throws
KrbException {
         EncTypeHandler handler = getEncHandler(eType);
 
@@ -223,7 +328,7 @@ public class EncryptionHandler {
 
     /**
      * Generate a secure and random key seeded with an existing encryption key.
-     * @param encKey
+     * @param encKey The encryption key
      * @return encryption key
      */
     public static EncryptionKey makeSubkey(EncryptionKey encKey) {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ec0f46b1/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/fast/FastUtil.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/fast/FastUtil.java
b/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/fast/FastUtil.java
index 8d1ee31..4644791 100644
--- a/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/fast/FastUtil.java
+++ b/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/fast/FastUtil.java
@@ -34,9 +34,13 @@ public class FastUtil {
 
     /**
      * Call the PRF function multiple times with the pepper prefixed with
-     * a count byte  to get enough bits of output.
+     * a count byte to get enough bits of output.
+     * @param key The encryption key
+     * @param pepper The pepper
+     * @param keyBytesLen The key bytes length
+     * @return The output byte
+     * @throws KrbException e
      */
-
     public static byte[] prfPlus(EncryptionKey key, String pepper,
                                  int keyBytesLen) throws KrbException {
         byte[] prfInbuf = new byte[pepper.length() + 1];
@@ -72,9 +76,10 @@ public class FastUtil {
 
     /**
      * Make an encryption key for replying.
-     * @param strengthenKey
-     * @param existingKey
+     * @param strengthenKey The strengthen key
+     * @param existingKey The existing key
      * @return encryption key
+     * @throws KrbException e
      */
     public static EncryptionKey makeReplyKey(EncryptionKey strengthenKey,
                                              EncryptionKey existingKey) throws KrbException
{
@@ -83,9 +88,10 @@ public class FastUtil {
 
     /**
      * Make an encryption key for armoring.
-     * @param subkey
-     * @param ticketKey
+     * @param subkey The sub key
+     * @param ticketKey The ticket key
      * @return encryption key
+     * @throws KrbException e
      */
     public static EncryptionKey makeArmorKey(EncryptionKey subkey,
                                              EncryptionKey ticketKey) throws KrbException
{

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ec0f46b1/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/key/AbstractKeyMaker.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/key/AbstractKeyMaker.java
b/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/key/AbstractKeyMaker.java
index f57f21b..fe0275e 100644
--- a/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/key/AbstractKeyMaker.java
+++ b/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/key/AbstractKeyMaker.java
@@ -37,7 +37,10 @@ public abstract class AbstractKeyMaker implements KeyMaker {
     }
 
     /**
-     * Visible for test
+     * Visible for test.
+     * @param password The password
+     * @param salt The salt
+     * @return The password salt
      */
     public static byte[] makePasswdSalt(String password, String salt) {
         char[] chars = new char[password.length() + salt.length()];

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ec0f46b1/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/key/DesKeyMaker.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/key/DesKeyMaker.java
b/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/key/DesKeyMaker.java
index b71cf69..c3c87c9 100644
--- a/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/key/DesKeyMaker.java
+++ b/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/key/DesKeyMaker.java
@@ -90,6 +90,7 @@ public class DesKeyMaker extends AbstractKeyMaker {
 
     /**
      * Visible for test
+     * {@inheritDoc}
      */
     public static byte[] fanFold(String string, String salt, byte[] paddedBytes) {
         if (paddedBytes == null) {
@@ -117,6 +118,7 @@ public class DesKeyMaker extends AbstractKeyMaker {
 
     /**
      * Visible for test
+     * {@inheritDoc}
      */
     public static byte[] intermediateKey(byte[] fanFoldedKey) {
         byte[] keyBytes = addParityBits(fanFoldedKey);
@@ -140,10 +142,10 @@ public class DesKeyMaker extends AbstractKeyMaker {
     }
 
     /**
-     * To turn a 54-bit block into a 64-bit block, see
+     * To turn a 56-bit block into a 64-bit block, see
      *  Ref. eighth_byte in random_to_key.c in MIT krb5
-     * @param bits56
-     * @return
+     * @param bits56 The 56-bit block
+     * @return The 64-bit block
      */
     private static byte[] getEightBits(byte[] bits56) {
         byte[] bits64 = new byte[8];
@@ -156,6 +158,7 @@ public class DesKeyMaker extends AbstractKeyMaker {
 
     /**
      * Note this isn't hit any test yet, and very probably problematic
+     * {@inheritDoc}
      */
     @Override
     public byte[] random2Key(byte[] randomBits) throws KrbException {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ec0f46b1/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/random/JavaRandom.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/random/JavaRandom.java
b/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/random/JavaRandom.java
index bc20330..91df072 100644
--- a/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/random/JavaRandom.java
+++ b/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/random/JavaRandom.java
@@ -22,7 +22,8 @@ package org.apache.kerby.kerberos.kerb.crypto.random;
 import java.security.SecureRandom;
 
 /**
- * Use jdk SecureRandom to implement RandomProvider, so it can be used on windows & linux.
+ * Use jdk {@link SecureRandom} to implement {@link RandomProvider},
+ * so it can be used on windows and linux.
  */
 
 public class JavaRandom implements RandomProvider {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ec0f46b1/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/random/RandomProvider.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/random/RandomProvider.java
b/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/random/RandomProvider.java
index 7d6b831..0320443 100644
--- a/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/random/RandomProvider.java
+++ b/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/random/RandomProvider.java
@@ -31,13 +31,13 @@ public interface RandomProvider {
     void init();
     /**
      * Provide entropy seed for the provider.
-     * @param seed
+     * @param seed The seed
      */
     void setSeed(byte[] seed);
 
     /**
      * Generate random bytes into the specified array.
-     * @param bytes
+     * @param bytes The bytes
      */
     void nextBytes(byte[] bytes);
 

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ec0f46b1/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/util/Camellia.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/util/Camellia.java
b/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/util/Camellia.java
index e2b2950..2690bb2 100644
--- a/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/util/Camellia.java
+++ b/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/util/Camellia.java
@@ -211,6 +211,10 @@ public class Camellia {
 
     /**
      * CBC encrypt nblocks blocks of data in place, using and updating iv.
+     * @param data The data
+     * @param offset The offset
+     * @param blocksNum The block number
+     * @param cipherState The cipher state
      */
     public void cbcEnc(byte[] data, int offset, int blocksNum, byte[] cipherState) {
         byte[] cipher = new byte[BLOCK_SIZE];
@@ -225,6 +229,10 @@ public class Camellia {
 
     /**
      * CBC encrypt nblocks blocks of data in place, using and updating iv.
+     * @param data The data
+     * @param offset The offset
+     * @param blocksNum The block number
+     * @param cipherState The cipher state
      */
     public void cbcDec(byte[] data, int offset, int blocksNum, byte[] cipherState) {
         byte[] lastBlock = new byte[BLOCK_SIZE];

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ec0f46b1/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/util/Des.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/util/Des.java
b/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/util/Des.java
index 7b8570e..7ad0eb1 100644
--- a/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/util/Des.java
+++ b/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/util/Des.java
@@ -75,6 +75,9 @@ public class Des {
 
     /**
      * MIT krb5 FIXUP(k) in s2k_des.c
+     * @param key The key byte
+     * @param offset The offset
+     * @param len The length
      */
     public static void fixKey(byte[] key, int offset, int len) {
         if (isWeakKey(key, offset, len)) {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ec0f46b1/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/util/Nfold.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/util/Nfold.java
b/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/util/Nfold.java
index ec8489f..a08f4ae 100644
--- a/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/util/Nfold.java
+++ b/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/util/Nfold.java
@@ -38,9 +38,12 @@ public class Nfold {
 
     /**
      * representation: msb first, assume n and k are multiples of 8, and
-     * that k>=16.  this is the case of all the cryptosystems which are
+     * that {@code k>=16}.  this is the case of all the cryptosystems which are
      * likely to be used.  this function can be replaced if that
      * assumption ever fails.
+     * @param inBytes The input bytes
+     * @param size The size
+     * @return The output byte
      */
     public static byte[] nfold(byte[] inBytes, int size) {
         int inBytesNum = inBytes.length; // count inBytes byte


Mime
View raw message