private @Nonnull String saltAndHash(@Nonnull String text) { return CommonUtil.sha256Digest(String.format("%s%s", text, CommonUtil.salt())); }
public static String decryptAndHashJuniper9CipherText(String key) { String privateSecret = decryptJuniper9CipherText(key); String saltedSecret = privateSecret + CommonUtil.salt(); String sha256Digest = CommonUtil.sha256Digest(saltedSecret); return sha256Digest; }
@Override public void exitS2sat_pre_shared_secret(S2sat_pre_shared_secretContext ctx) { String secret = ctx.secret.getText(); String saltedSecret = secret + CommonUtil.salt(); String secretHash = CommonUtil.sha256Digest(saltedSecret); _currentIpsecPeer.setAuthenticationPreSharedSecretHash(secretHash); }
@Override public void exitSyr_encrypted_password(Syr_encrypted_passwordContext ctx) { String hash = ctx.password.getText(); String rehashedPassword = CommonUtil.sha256Digest(hash + CommonUtil.salt()); _currentLogicalSystem.getJf().setRootAuthenticationEncryptedPassword(rehashedPassword); }
_ikePreSharedKeyHash = CommonUtil.sha256Digest( getText(ikeElement, AwsVpcEntity.XML_KEY_PRE_SHARED_KEY) + CommonUtil.salt());
@Override public void exitU_password(U_passwordContext ctx) { String passwordString; if (ctx.up_arista_md5() != null) { passwordString = ctx.up_arista_md5().pass.getText(); } else if (ctx.up_arista_sha512() != null) { passwordString = ctx.up_arista_sha512().pass.getText(); } else if (ctx.up_cisco() != null) { passwordString = ctx.up_cisco().up_cisco_tail().pass.getText(); } else if (ctx.NOPASSWORD() != null) { passwordString = ""; } else { throw new BatfishException("Missing username password handling"); } String passwordRehash = CommonUtil.sha256Digest(passwordString + CommonUtil.salt()); _currentUser.setPassword(passwordRehash); }
@Override public void exitEnable_secret(Enable_secretContext ctx) { String password; if (ctx.double_quoted_string() != null) { password = unquote(ctx.double_quoted_string().getText()); } else { password = ctx.pass.getText() + CommonUtil.salt(); } String passwordRehash = CommonUtil.sha256Digest(password); _configuration.getCf().setEnableSecret(passwordRehash); }
@Override public void exitCkr_psk(Ckr_pskContext ctx) { Ip wildCardMask = ctx.wildcard_mask == null ? Ip.MAX : toIp(ctx.wildcard_mask); _currentKeyring.setKey( CommonUtil.sha256Digest(ctx.variable_permissive().getText() + CommonUtil.salt())); _currentKeyring.setRemoteIdentity( new IpWildcard(toIp(ctx.ip_address), wildCardMask.inverted())); }
@Override public void exitIfvrrp_authentication(Ifvrrp_authenticationContext ctx) { String hashedAuthenticationText = CommonUtil.sha256Digest(ctx.text.getText() + CommonUtil.salt()); for (Interface iface : _currentInterfaces) { String ifaceName = iface.getName(); VrrpGroup vrrpGroup = _configuration .getVrrpGroups() .computeIfAbsent(ifaceName, n -> new VrrpInterface()) .getVrrpGroups() .computeIfAbsent(_currentVrrpGroupNum, VrrpGroup::new); vrrpGroup.setAuthenticationTextHash(hashedAuthenticationText); } }