// Path: src/main/java/com/healthmarketscience/jackcess/crypt/InvalidCryptoConfigurationException.java
// public class InvalidCryptoConfigurationException extends IllegalStateException
// {
//   private static final long serialVersionUID = 20170130L;
// 
//   public InvalidCryptoConfigurationException(String msg) {
//     super(msg);
//   }
// 
//   public InvalidCryptoConfigurationException(String msg, Throwable t) {
//     super(msg, t);
//   }
// }


import java.nio.ByteBuffer;
import com.healthmarketscience.jackcess.crypt.InvalidCryptoConfigurationException;
import com.healthmarketscience.jackcess.impl.ByteUtil;
/*
Copyright (c) 2013 James Ahlborn

Licensed 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 com.healthmarketscience.jackcess.crypt.impl.office;



/**
 *
 * @author James Ahlborn
 */
public class EncryptionVerifier
{
  private final static int SALT_SIZE = 16;
  private final static int ENC_VERIFIER_SIZE = 16;

  private final int _saltSize;
  private final byte[] _salt;
  private final byte[] _encryptedVerifier;
  private final int _verifierHashSize;
  private final byte[] _encryptedVerifierHash;

  public EncryptionVerifier(ByteBuffer buffer,
                            EncryptionHeader.CryptoAlgorithm cryptoAlg)
  {
    // OC: 2.3.3 EncryptionVerifier Structure
    _saltSize = buffer.getInt();
    if(_saltSize != SALT_SIZE) {
// Path: src/main/java/com/healthmarketscience/jackcess/crypt/InvalidCryptoConfigurationException.java
// public class InvalidCryptoConfigurationException extends IllegalStateException
// {
//   private static final long serialVersionUID = 20170130L;
// 
//   public InvalidCryptoConfigurationException(String msg) {
//     super(msg);
//   }
// 
//   public InvalidCryptoConfigurationException(String msg, Throwable t) {
//     super(msg, t);
//   }
// }


// Path: src/main/java/com/healthmarketscience/jackcess/crypt/impl/office/EncryptionVerifier.java
import java.nio.ByteBuffer;
import com.healthmarketscience.jackcess.crypt.InvalidCryptoConfigurationException;
import com.healthmarketscience.jackcess.impl.ByteUtil;

/*
Copyright (c) 2013 James Ahlborn

Licensed 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 com.healthmarketscience.jackcess.crypt.impl.office;



/**
 *
 * @author James Ahlborn
 */
public class EncryptionVerifier
{
  private final static int SALT_SIZE = 16;
  private final static int ENC_VERIFIER_SIZE = 16;

  private final int _saltSize;
  private final byte[] _salt;
  private final byte[] _encryptedVerifier;
  private final int _verifierHashSize;
  private final byte[] _encryptedVerifierHash;

  public EncryptionVerifier(ByteBuffer buffer,
                            EncryptionHeader.CryptoAlgorithm cryptoAlg)
  {
    // OC: 2.3.3 EncryptionVerifier Structure
    _saltSize = buffer.getInt();
    if(_saltSize != SALT_SIZE) {
      throw new InvalidCryptoConfigurationException("salt size " + _saltSize + " must be " + SALT_SIZE);