1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.healthmarketscience.jackcess.crypt.impl.office;
18
19 import java.nio.ByteBuffer;
20
21 import com.healthmarketscience.jackcess.crypt.InvalidCryptoConfigurationException;
22 import com.healthmarketscience.jackcess.impl.ByteUtil;
23
24
25
26
27
28 public class EncryptionVerifier
29 {
30 private final static int SALT_SIZE = 16;
31 private final static int ENC_VERIFIER_SIZE = 16;
32
33 private final int _saltSize;
34 private final byte[] _salt;
35 private final byte[] _encryptedVerifier;
36 private final int _verifierHashSize;
37 private final byte[] _encryptedVerifierHash;
38
39 public EncryptionVerifier(ByteBuffer buffer,
40 EncryptionHeader.CryptoAlgorithm cryptoAlg)
41 {
42
43 _saltSize = buffer.getInt();
44 if(_saltSize != SALT_SIZE) {
45 throw new InvalidCryptoConfigurationException("salt size " + _saltSize + " must be " + SALT_SIZE);
46 }
47 _salt = ByteUtil.getBytes(buffer, _saltSize);
48 _encryptedVerifier = ByteUtil.getBytes(buffer, ENC_VERIFIER_SIZE);
49 _verifierHashSize = buffer.getInt();
50 _encryptedVerifierHash = ByteUtil.getBytes(
51 buffer, cryptoAlg.getEncryptedVerifierHashLen());
52 }
53
54 public int getSaltSize() {
55 return _saltSize;
56 }
57
58 public byte[] getSalt() {
59 return _salt;
60 }
61
62 public byte[] getEncryptedVerifier() {
63 return _encryptedVerifier;
64 }
65
66 public int getVerifierHashSize() {
67 return _verifierHashSize;
68 }
69
70 public byte[] getEncryptedVerifierHash() {
71 return _encryptedVerifierHash;
72 }
73
74 }