ScramSha256.java

 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 Hashing.hmacSha256(key);
23    }
24
25    @Override
26    protected HashFunction getDigest() {
27        return Hashing.sha256();
28    }
29    @Override
30    public int getPriority() {
31        return 25;
32    }
33
34    @Override
35    public String getMechanism() {
36        return MECHANISM;
37    }
38}