Constant time base64

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld
2017-08-08 18:22:41 +02:00
committed by Samuel Holland
parent f8d8e5e23e
commit f6b864d4e7
3 changed files with 82 additions and 20 deletions
@@ -6,6 +6,7 @@ import android.databinding.Observable;
import com.wireguard.android.BR;
import com.wireguard.crypto.Keypair;
import com.wireguard.crypto.KeyEncoding;
/**
* Represents the configuration for a WireGuard interface (an [Interface] block).
@@ -90,7 +91,7 @@ public class Interface extends BaseObservable implements Observable {
public void setPrivateKey(String privateKey) {
// Avoid exceptions from Keypair while the user is typing.
if (privateKey.length() != Keypair.KEY_STRING_LENGTH)
if (privateKey.length() != KeyEncoding.WG_KEY_LEN_BASE64)
return;
keypair = new Keypair(privateKey);
notifyPropertyChanged(BR.privateKey);