⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 functions.java

📁 java 实现的签名方案
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
      mechansimNames.put(new Long(PKCS11Constants.CKM_IDEA_ECB), PKCS11Constants.NAME_CKM_IDEA_ECB);      mechansimNames.put(new Long(PKCS11Constants.CKM_IDEA_CBC), PKCS11Constants.NAME_CKM_IDEA_CBC);      mechansimNames.put(new Long(PKCS11Constants.CKM_IDEA_MAC), PKCS11Constants.NAME_CKM_IDEA_MAC);      mechansimNames.put(new Long(PKCS11Constants.CKM_IDEA_MAC_GENERAL), PKCS11Constants.NAME_CKM_IDEA_MAC_GENERAL);      mechansimNames.put(new Long(PKCS11Constants.CKM_IDEA_CBC_PAD), PKCS11Constants.NAME_CKM_IDEA_CBC_PAD);      mechansimNames.put(new Long(PKCS11Constants.CKM_GENERIC_SECRET_KEY_GEN), PKCS11Constants.NAME_CKM_GENERIC_SECRET_KEY_GEN);      mechansimNames.put(new Long(PKCS11Constants.CKM_CONCATENATE_BASE_AND_KEY), PKCS11Constants.NAME_CKM_CONCATENATE_BASE_AND_KEY);      mechansimNames.put(new Long(PKCS11Constants.CKM_CONCATENATE_BASE_AND_DATA), PKCS11Constants.NAME_CKM_CONCATENATE_BASE_AND_DATA);      mechansimNames.put(new Long(PKCS11Constants.CKM_CONCATENATE_DATA_AND_BASE), PKCS11Constants.NAME_CKM_CONCATENATE_DATA_AND_BASE);      mechansimNames.put(new Long(PKCS11Constants.CKM_XOR_BASE_AND_DATA), PKCS11Constants.NAME_CKM_XOR_BASE_AND_DATA);      mechansimNames.put(new Long(PKCS11Constants.CKM_EXTRACT_KEY_FROM_KEY), PKCS11Constants.NAME_CKM_EXTRACT_KEY_FROM_KEY);      mechansimNames.put(new Long(PKCS11Constants.CKM_SSL3_PRE_MASTER_KEY_GEN), PKCS11Constants.NAME_CKM_SSL3_PRE_MASTER_KEY_GEN);      mechansimNames.put(new Long(PKCS11Constants.CKM_SSL3_MASTER_KEY_DERIVE), PKCS11Constants.NAME_CKM_SSL3_MASTER_KEY_DERIVE);      mechansimNames.put(new Long(PKCS11Constants.CKM_SSL3_KEY_AND_MAC_DERIVE), PKCS11Constants.NAME_CKM_SSL3_KEY_AND_MAC_DERIVE);      mechansimNames.put(new Long(PKCS11Constants.CKM_SSL3_MASTER_KEY_DERIVE_DH), PKCS11Constants.NAME_CKM_SSL3_MASTER_KEY_DERIVE_DH);      mechansimNames.put(new Long(PKCS11Constants.CKM_TLS_PRE_MASTER_KEY_GEN), PKCS11Constants.NAME_CKM_TLS_PRE_MASTER_KEY_GEN);      mechansimNames.put(new Long(PKCS11Constants.CKM_TLS_MASTER_KEY_DERIVE), PKCS11Constants.NAME_CKM_TLS_MASTER_KEY_DERIVE);      mechansimNames.put(new Long(PKCS11Constants.CKM_TLS_KEY_AND_MAC_DERIVE), PKCS11Constants.NAME_CKM_TLS_KEY_AND_MAC_DERIVE);      mechansimNames.put(new Long(PKCS11Constants.CKM_TLS_MASTER_KEY_DERIVE_DH), PKCS11Constants.NAME_CKM_TLS_MASTER_KEY_DERIVE_DH);      mechansimNames.put(new Long(PKCS11Constants.CKM_SSL3_MD5_MAC), PKCS11Constants.NAME_CKM_SSL3_MD5_MAC);      mechansimNames.put(new Long(PKCS11Constants.CKM_SSL3_SHA1_MAC), PKCS11Constants.NAME_CKM_SSL3_SHA1_MAC);      mechansimNames.put(new Long(PKCS11Constants.CKM_MD5_KEY_DERIVATION), PKCS11Constants.NAME_CKM_MD5_KEY_DERIVATION);      mechansimNames.put(new Long(PKCS11Constants.CKM_MD2_KEY_DERIVATION), PKCS11Constants.NAME_CKM_MD2_KEY_DERIVATION);      mechansimNames.put(new Long(PKCS11Constants.CKM_SHA1_KEY_DERIVATION), PKCS11Constants.NAME_CKM_SHA1_KEY_DERIVATION);      mechansimNames.put(new Long(PKCS11Constants.CKM_PBE_MD2_DES_CBC), PKCS11Constants.NAME_CKM_PBE_MD2_DES_CBC);      mechansimNames.put(new Long(PKCS11Constants.CKM_PBE_MD5_DES_CBC), PKCS11Constants.NAME_CKM_PBE_MD5_DES_CBC);      mechansimNames.put(new Long(PKCS11Constants.CKM_PBE_MD5_CAST_CBC), PKCS11Constants.NAME_CKM_PBE_MD5_CAST_CBC);      mechansimNames.put(new Long(PKCS11Constants.CKM_PBE_MD5_CAST3_CBC), PKCS11Constants.NAME_CKM_PBE_MD5_CAST3_CBC);      mechansimNames.put(new Long(PKCS11Constants.CKM_PBE_MD5_CAST5_CBC), PKCS11Constants.NAME_CKM_PBE_MD5_CAST5_CBC);      mechansimNames.put(new Long(PKCS11Constants.CKM_PBE_MD5_CAST128_CBC), PKCS11Constants.NAME_CKM_PBE_MD5_CAST128_CBC);      mechansimNames.put(new Long(PKCS11Constants.CKM_PBE_SHA1_CAST5_CBC), PKCS11Constants.NAME_CKM_PBE_SHA1_CAST5_CBC);      mechansimNames.put(new Long(PKCS11Constants.CKM_PBE_SHA1_CAST128_CBC), PKCS11Constants.NAME_CKM_PBE_SHA1_CAST128_CBC);      mechansimNames.put(new Long(PKCS11Constants.CKM_PBE_SHA1_RC4_128), PKCS11Constants.NAME_CKM_PBE_SHA1_RC4_128);      mechansimNames.put(new Long(PKCS11Constants.CKM_PBE_SHA1_RC4_40), PKCS11Constants.NAME_CKM_PBE_SHA1_RC4_40);      mechansimNames.put(new Long(PKCS11Constants.CKM_PBE_SHA1_DES3_EDE_CBC), PKCS11Constants.NAME_CKM_PBE_SHA1_DES3_EDE_CBC);      mechansimNames.put(new Long(PKCS11Constants.CKM_PBE_SHA1_DES2_EDE_CBC), PKCS11Constants.NAME_CKM_PBE_SHA1_DES2_EDE_CBC);      mechansimNames.put(new Long(PKCS11Constants.CKM_PBE_SHA1_RC2_128_CBC), PKCS11Constants.NAME_CKM_PBE_SHA1_RC2_128_CBC);      mechansimNames.put(new Long(PKCS11Constants.CKM_PBE_SHA1_RC2_40_CBC), PKCS11Constants.NAME_CKM_PBE_SHA1_RC2_40_CBC);      mechansimNames.put(new Long(PKCS11Constants.CKM_PKCS5_PBKD2), PKCS11Constants.NAME_CKM_PKCS5_PBKD2);      mechansimNames.put(new Long(PKCS11Constants.CKM_PBA_SHA1_WITH_SHA1_HMAC), PKCS11Constants.NAME_CKM_PBA_SHA1_WITH_SHA1_HMAC);      mechansimNames.put(new Long(PKCS11Constants.CKM_KEY_WRAP_LYNKS), PKCS11Constants.NAME_CKM_KEY_WRAP_LYNKS);      mechansimNames.put(new Long(PKCS11Constants.CKM_KEY_WRAP_SET_OAEP), PKCS11Constants.NAME_CKM_KEY_WRAP_SET_OAEP);      mechansimNames.put(new Long(PKCS11Constants.CKM_SKIPJACK_KEY_GEN), PKCS11Constants.NAME_CKM_SKIPJACK_KEY_GEN);      mechansimNames.put(new Long(PKCS11Constants.CKM_SKIPJACK_ECB64), PKCS11Constants.NAME_CKM_SKIPJACK_ECB64);      mechansimNames.put(new Long(PKCS11Constants.CKM_SKIPJACK_CBC64), PKCS11Constants.NAME_CKM_SKIPJACK_CBC64);      mechansimNames.put(new Long(PKCS11Constants.CKM_SKIPJACK_OFB64), PKCS11Constants.NAME_CKM_SKIPJACK_OFB64);      mechansimNames.put(new Long(PKCS11Constants.CKM_SKIPJACK_CFB64), PKCS11Constants.NAME_CKM_SKIPJACK_CFB64);      mechansimNames.put(new Long(PKCS11Constants.CKM_SKIPJACK_CFB32), PKCS11Constants.NAME_CKM_SKIPJACK_CFB32);      mechansimNames.put(new Long(PKCS11Constants.CKM_SKIPJACK_CFB16), PKCS11Constants.NAME_CKM_SKIPJACK_CFB16);      mechansimNames.put(new Long(PKCS11Constants.CKM_SKIPJACK_CFB8), PKCS11Constants.NAME_CKM_SKIPJACK_CFB8);      mechansimNames.put(new Long(PKCS11Constants.CKM_SKIPJACK_WRAP), PKCS11Constants.NAME_CKM_SKIPJACK_WRAP);      mechansimNames.put(new Long(PKCS11Constants.CKM_SKIPJACK_PRIVATE_WRAP), PKCS11Constants.NAME_CKM_SKIPJACK_PRIVATE_WRAP);      mechansimNames.put(new Long(PKCS11Constants.CKM_SKIPJACK_RELAYX), PKCS11Constants.NAME_CKM_SKIPJACK_RELAYX);      mechansimNames.put(new Long(PKCS11Constants.CKM_KEA_KEY_PAIR_GEN), PKCS11Constants.NAME_CKM_KEA_KEY_PAIR_GEN);      mechansimNames.put(new Long(PKCS11Constants.CKM_KEA_KEY_DERIVE), PKCS11Constants.NAME_CKM_KEA_KEY_DERIVE);      mechansimNames.put(new Long(PKCS11Constants.CKM_FORTEZZA_TIMESTAMP), PKCS11Constants.NAME_CKM_FORTEZZA_TIMESTAMP);      mechansimNames.put(new Long(PKCS11Constants.CKM_BATON_KEY_GEN), PKCS11Constants.NAME_CKM_BATON_KEY_GEN);      mechansimNames.put(new Long(PKCS11Constants.CKM_BATON_ECB128), PKCS11Constants.NAME_CKM_BATON_ECB128);      mechansimNames.put(new Long(PKCS11Constants.CKM_BATON_ECB96), PKCS11Constants.NAME_CKM_BATON_ECB96);      mechansimNames.put(new Long(PKCS11Constants.CKM_BATON_CBC128), PKCS11Constants.NAME_CKM_BATON_CBC128);      mechansimNames.put(new Long(PKCS11Constants.CKM_BATON_COUNTER), PKCS11Constants.NAME_CKM_BATON_COUNTER);      mechansimNames.put(new Long(PKCS11Constants.CKM_BATON_SHUFFLE), PKCS11Constants.NAME_CKM_BATON_SHUFFLE);      mechansimNames.put(new Long(PKCS11Constants.CKM_BATON_WRAP), PKCS11Constants.NAME_CKM_BATON_WRAP);      mechansimNames.put(new Long(PKCS11Constants.CKM_ECDSA_KEY_PAIR_GEN), PKCS11Constants.NAME_CKM_ECDSA_KEY_PAIR_GEN);      mechansimNames.put(new Long(PKCS11Constants.CKM_EC_KEY_PAIR_GEN), PKCS11Constants.NAME_CKM_EC_KEY_PAIR_GEN);      mechansimNames.put(new Long(PKCS11Constants.CKM_ECDSA), PKCS11Constants.NAME_CKM_ECDSA);      mechansimNames.put(new Long(PKCS11Constants.CKM_ECDSA_SHA1), PKCS11Constants.NAME_CKM_ECDSA_SHA1);      mechansimNames.put(new Long(PKCS11Constants.CKM_ECDH1_DERIVE), PKCS11Constants.NAME_CKM_ECDH1_DERIVE);      mechansimNames.put(new Long(PKCS11Constants.CKM_ECDH1_COFACTOR_DERIVE), PKCS11Constants.NAME_CKM_ECDH1_COFACTOR_DERIVE);      mechansimNames.put(new Long(PKCS11Constants.CKM_ECMQV_DERIVE), PKCS11Constants.NAME_CKM_ECMQV_DERIVE);      mechansimNames.put(new Long(PKCS11Constants.CKM_JUNIPER_KEY_GEN), PKCS11Constants.NAME_CKM_JUNIPER_KEY_GEN);      mechansimNames.put(new Long(PKCS11Constants.CKM_JUNIPER_ECB128), PKCS11Constants.NAME_CKM_JUNIPER_ECB128);      mechansimNames.put(new Long(PKCS11Constants.CKM_JUNIPER_CBC128), PKCS11Constants.NAME_CKM_JUNIPER_CBC128);      mechansimNames.put(new Long(PKCS11Constants.CKM_JUNIPER_COUNTER), PKCS11Constants.NAME_CKM_JUNIPER_COUNTER);      mechansimNames.put(new Long(PKCS11Constants.CKM_JUNIPER_SHUFFLE), PKCS11Constants.NAME_CKM_JUNIPER_SHUFFLE);      mechansimNames.put(new Long(PKCS11Constants.CKM_JUNIPER_WRAP), PKCS11Constants.NAME_CKM_JUNIPER_WRAP);      mechansimNames.put(new Long(PKCS11Constants.CKM_FASTHASH), PKCS11Constants.NAME_CKM_FASTHASH);      mechansimNames.put(new Long(PKCS11Constants.CKM_AES_KEY_GEN), PKCS11Constants.NAME_CKM_AES_KEY_GEN);      mechansimNames.put(new Long(PKCS11Constants.CKM_AES_ECB), PKCS11Constants.NAME_CKM_AES_ECB);      mechansimNames.put(new Long(PKCS11Constants.CKM_AES_CBC), PKCS11Constants.NAME_CKM_AES_CBC);      mechansimNames.put(new Long(PKCS11Constants.CKM_AES_MAC), PKCS11Constants.NAME_CKM_AES_MAC);      mechansimNames.put(new Long(PKCS11Constants.CKM_AES_MAC_GENERAL), PKCS11Constants.NAME_CKM_AES_MAC_GENERAL);      mechansimNames.put(new Long(PKCS11Constants.CKM_AES_CBC_PAD), PKCS11Constants.NAME_CKM_AES_CBC_PAD);      mechansimNames.put(new Long(PKCS11Constants.CKM_DSA_PARAMETER_GEN), PKCS11Constants.NAME_CKM_DSA_PARAMETER_GEN);      mechansimNames.put(new Long(PKCS11Constants.CKM_DH_PKCS_PARAMETER_GEN), PKCS11Constants.NAME_CKM_DH_PKCS_PARAMETER_GEN);      mechansimNames.put(new Long(PKCS11Constants.CKM_X9_42_DH_PARAMETER_GEN), PKCS11Constants.NAME_CKM_X9_42_DH_PARAMETER_GEN);      mechansimNames.put(new Long(PKCS11Constants.CKM_VENDOR_DEFINED), PKCS11Constants.NAME_CKM_VENDOR_DEFINED);      mechansimNames_ = mechansimNames;    }    Long mechansimCodeObject = new Long(mechansimCode);    Object entry = mechansimNames_.get(mechansimCodeObject);    String mechanismName = (entry != null)                           ? entry.toString()                           : "Unknwon mechanism with code: 0x" + toFullHexString(mechansimCode);    return mechanismName ;  }  /**   * Converts the long value classType to a string representation of it.   *   * @param classType The classType to be converted.   * @return The string representation of the classType.   */  public static String classTypeToString(long classType) {    String name;    if (classType == PKCS11Constants.CKO_DATA) {      name ="CKO_DATA";    } else if (classType == PKCS11Constants.CKO_CERTIFICATE) {      name ="CKO_CERTIFICATE";    } else if (classType == PKCS11Constants.CKO_PUBLIC_KEY) {      name ="CKO_PUBLIC_KEY";    } else if (classType == PKCS11Constants.CKO_PRIVATE_KEY) {      name ="CKO_PRIVATE_KEY";    } else if (classType == PKCS11Constants.CKO_SECRET_KEY) {      name ="CKO_SECRET_KEY";    } else if (classType == PKCS11Constants.CKO_HW_FEATURE) {      name ="CKO_HW_FEATURE";    } else if (classType == PKCS11Constants.CKO_DOMAIN_PARAMETERS) {      name ="CKO_DOMAIN_PARAMETERS";    } else if (classType == PKCS11Constants.CKO_VENDOR_DEFINED) {      name ="CKO_VENDOR_DEFINED";    } else {      name ="ERROR: unknown classType with code: 0x" + toFullHexString(classType);    }    return name;  }  /**   * Check the given arrays for equalitiy. This method considers both arrays as   * equal, if both are <code>null</code> or both have the same length and   * contain exactly the same byte values.   *   * @param array1 The first array.   * @param array2 The second array.   * @return True, if both arrays are <code>null</code> or both have the same   *         length and contain exactly the same byte values. False, otherwise.   * @preconditions   * @postconditions   */  public static boolean equals(byte[] array1, byte[] array2) {    boolean equal = false;    if (array1 == array2) {      equal = true;    } else if ((array1 != null) && (array2 != null)) {      int length = array1.length;      if (length == array2.length) {        equal = true;        for (int i = 0; i < length; i++) {          if (array1[i] != array2[i]) {            equal = false;            break;          }        }      } else {        equal = false;      }    } else {      equal = false;    }    return equal ;  }  /**   * Check the given arrays for equalitiy. This method considers both arrays as   * equal, if both are <code>null</code> or both have the same length and   * contain exactly the same char values.   *   * @param array1 The first array.   * @param array2 The second array.   * @return True, if both arrays are <code>null</code> or both have the same   *         length and contain exactly the same char values. False, otherwise.   * @preconditions   * @postconditions   */  public static boolean equals(char[] array1, char[] array2) {    boolean equal = false;    if (array1 == array2) {      equal = true;    } else if ((array1 != null) && (array2 != null)) {      int length = array1.length;      if (length == array2.length) {        equal = true;        for (int i = 0; i < length; i++) {          if (array1[i] != array2[i]) {            equal = false;            break;          }        }      } else {        equal = false;      }    } else {      equal = false;    }    return equal ;  }  /**   * Check the given dates for equalitiy. This method considers both dates as   * equal, if both are <code>null</code> or both contain exactly the same char   * values.   *   * @param date1 The first date.   * @param date2 The second date.   * @return True, if both dates are <code>null</code> or both contain the same   *         char values. False, otherwise.   * @preconditions   * @postconditions   */  public static boolean equals(CK_DATE date1, CK_DATE date2) {    boolean equal = false;    if (date1 == date2) {      equal = true;    } else if ((date1 != null) && (date2 != null)) {      equal = equals(date1.year, date2.year)              && equals(date1.month, date2.month)              && equals(date1.day, date2.day);    } else {      equal = false;    }    return equal ;  }  /**   * Calculate a hash code for the given byte array.   *   * @param array The byte array.   * @return A hash code for the given array.   * @preconditions   * @postconditions   */  public static int hashCode(byte[] array) {    int hash = 0;    if (array != null) {      for (int i = 0; (i < 4) && (i < array.length); i++) {        hash ^= ((int) (0xFF & array[i])) << ((i%4) << 3);      }    }    return hash ;  }  /**   * Calculate a hash code for the given char array.   *   * @param array The char array.   * @return A hash code for the given array.   * @preconditions   * @postconditions   */  public static int hashCode(char[] array) {    int hash = 0;    if (array != null) {      for (int i = 0; (i < 4) && (i < array.length); i++) {        hash ^= ((int) (0xFFFF & array[i])) << ((i%2) << 4);      }    }    return hash ;  }  /**   * Calculate a hash code for the given date object.   *   * @param date The date object.   * @return A hash code for the given date.   * @preconditions   * @postconditions

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -