1package eu.siacs.conversations.crypto.sasl;
2
3import com.google.common.hash.HashFunction;
4import com.google.common.hash.Hashing;
5
6import org.bouncycastle.crypto.Digest;
7import org.bouncycastle.crypto.digests.SHA256Digest;
8import org.bouncycastle.crypto.macs.HMac;
9
10import eu.siacs.conversations.entities.Account;
11
12public class ScramSha256 extends ScramMechanism {
13
14 public static final String MECHANISM = "SCRAM-SHA-256";
15
16 public ScramSha256(final Account account) {
17 super(account, ChannelBinding.NONE);
18 }
19
20 @Override
21 protected HashFunction getHMac(final byte[] key) {
22 return (key == null || key.length == 0)
23 ? Hashing.hmacSha256(EMPTY_KEY)
24 : Hashing.hmacSha256(key);
25 }
26
27 @Override
28 protected HashFunction getDigest() {
29 return Hashing.sha256();
30 }
31 @Override
32 public int getPriority() {
33 return 25;
34 }
35
36 @Override
37 public String getMechanism() {
38 return MECHANISM;
39 }
40}