private byte[] buildFileAuthTag() throws FileEncryptionException {
  SecretKey key=backEncRandomAccessFile.shareKey;
  if (key == null || key.getEncoded().length == 0) {
    throw new FileEncryptionException("Invalid file encryption key in encrypting random access file!");
  }
 else {
    authTagHMac.reset();
    KeyParameter keyParameter=new KeyParameter(key.getEncoded());
    authTagHMac.init(keyParameter);
  }
  if (atagList.size() == 0) {
    throw new FileEncryptionException("No chunk authentication tags have been set yet!");
  }
 else {
    for (int i=0; i < atagList.size(); i++) {
      byte[] curChunkTag=atagList.get(i);
      if ((curChunkTag == null) || (curChunkTag.length != CHUNK_AUTH_TAG_LENGTH)) {
        throw new FileEncryptionException("Invalid chunk authentication tag in auth tag table at offset: " + i);
      }
 else {
        authTagHMac.update(curChunkTag,0,CHUNK_AUTH_TAG_LENGTH);
      }
    }
    byte[] tmp=new byte[AUTH_TAG_SIZE];
    authTagHMac.doFinal(tmp,0);
    return tmp;
  }
}

private byte [ ] buildFileAuthTag ( ) throws FileEncryptionException { SecretKey key = backEncRandomAccessFile . shareKey ; if ( key == null || key . getEncoded ( ) . length == 0 ) { throw new FileEncryptionException ( "Invalid file encryption key in encrypting random access file!" ) ; } else { authTagHMac . reset ( ) ; KeyParameter keyParameter = new KeyParameter ( key . getEncoded ( ) ) ; authTagHMac . init ( keyParameter ) ; } if ( atagList . size ( ) == 0 ) { throw new FileEncryptionException ( "No chunk authentication tags have been set yet!" ) ; } else { for ( int i = 0 ; i < atagList . size ( ) ; i ++ ) { byte [ ] curChunkTag = atagList . get ( i ) ; if ( ( curChunkTag == null ) || ( curChunkTag . length != CHUNK_AUTH_TAG_LENGTH ) ) { throw new FileEncryptionException ( "Invalid chunk authentication tag in auth tag table at offset: " + i ) ; } else { authTagHMac . update ( curChunkTag , 0 , CHUNK_AUTH_TAG_LENGTH ) ; } } byte [ ] tmp = new byte [ AUTH_TAG_SIZE ] ; authTagHMac . doFinal ( tmp , 0 ) ; return tmp ; } }
builds and returns the root authentication tag
