예제 #1
0
 // KrbSafe, KrbTgsReq
 public Checksum(int new_cksumType, byte[] data, EncryptionKey key, int usage)
     throws KdcErrException, KrbApErrException, KrbCryptoException {
   cksumType = new_cksumType;
   CksumType cksumEngine = CksumType.getInstance(cksumType);
   if (!cksumEngine.isSafe()) throw new KrbApErrException(Krb5.KRB_AP_ERR_INAPP_CKSUM);
   checksum = cksumEngine.calculateKeyedChecksum(data, data.length, key.getBytes(), usage);
 }
예제 #2
0
  /**
   * Constructs a new Checksum by calculating the checksum over the data using specified checksum
   * type.
   *
   * @new_cksumType the type of checksum.
   * @data the data that needs to be performed a checksum calculation on.
   */
  public Checksum(int new_cksumType, byte[] data) throws KdcErrException, KrbCryptoException {

    cksumType = new_cksumType;
    CksumType cksumEngine = CksumType.getInstance(cksumType);
    if (!cksumEngine.isSafe()) {
      checksum = cksumEngine.calculateChecksum(data, data.length);
    } else {
      throw new KdcErrException(Krb5.KRB_AP_ERR_INAPP_CKSUM);
    }
  }
예제 #3
0
 boolean isEqual(Checksum cksum) throws KdcErrException {
   if (cksumType != cksum.cksumType) return false;
   CksumType cksumEngine = CksumType.getInstance(cksumType);
   return CksumType.isChecksumEqual(checksum, cksum.checksum);
 }
예제 #4
0
 /** Verifies the keyed checksum over the data passed in. */
 public boolean verifyKeyedChecksum(byte[] data, EncryptionKey key, int usage)
     throws KdcErrException, KrbApErrException, KrbCryptoException {
   CksumType cksumEngine = CksumType.getInstance(cksumType);
   if (!cksumEngine.isSafe()) throw new KrbApErrException(Krb5.KRB_AP_ERR_INAPP_CKSUM);
   return cksumEngine.verifyKeyedChecksum(data, data.length, key.getBytes(), checksum, usage);
 }