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.SHA512Digest;
8import org.bouncycastle.crypto.macs.HMac;
9
10import eu.siacs.conversations.entities.Account;
11
12public class ScramSha512 extends ScramMechanism {
13
14 public static final String MECHANISM = "SCRAM-SHA-512";
15
16 public ScramSha512(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.hmacSha512(EMPTY_KEY)
24 : Hashing.hmacSha512(key);
25 }
26
27 @Override
28 protected HashFunction getDigest() {
29 return Hashing.sha512();
30 }
31
32 @Override
33 public int getPriority() {
34 return 30;
35 }
36
37 @Override
38 public String getMechanism() {
39 return MECHANISM;
40 }
41}