This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LoginWithEmailNormal | |
{ | |
public void LoginWithEmail() | |
{ | |
var loginReq = new LoginWithEmailAddressRequest | |
{ | |
Email = EmailField.text, | |
Password = PasswordField.text | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LoginWithEmailPinning | |
{ | |
public void LoginWithEmail() | |
{ | |
var loginReq = new LoginWithEmailAddressRequest | |
{ | |
Email = EmailField.text, | |
Password = PasswordField.text | |
}; | |
PlayFab.Internal.PlayFabWebRequest.CustomCertValidationHook = CertPinning.CertCheck; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CertPinning | |
{ | |
public static bool CertCheck(object sender, X509Certificate certificate, | |
X509Chain chain, SslPolicyErrors sslPolicyErrors) | |
{ | |
String certSha256FingerprintHex = "xxxxxxxxxxxxxxxxxx"; | |
if (certificate == null){ | |
return false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void CreateKeyPair() | |
{ | |
ECKeyPairGenerator keyPairGenerator = (ECKeyPairGenerator)GeneratorUtilities.GetKeyPairGenerator("ECDH"); | |
keyPairGenerator.Init(new KeyGenerationParameters(new SecureRandom(), 521)); | |
AsymmetricCipherKeyPair keyPair = keyPairGenerator.GenerateKeyPair(); | |
ECPrivateKeyParameters clientPrivKey = (ECPrivateKeyParameters)keyPair.Private; | |
ECPublicKeyParameters clientPubKey = (ECPublicKeyParameters)keyPair.Public; | |
StringWriter sw1 = new StringWriter(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PublicKeyDto | |
{ | |
public String PublicKey { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class KeyExchangeDto | |
{ | |
public int Code { get; set; } | |
public String KeyId { get; set; } | |
public String Salt { get; set; } | |
public String ServerPublicKey { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static String EcPemtoDer(String pemKey, String type) | |
{ | |
String trim = ""; | |
if(type == "public") | |
{ | |
trim = pemKey.Replace("-----BEGIN PUBLIC KEY-----\n", "") | |
.Replace("\n-----END PUBLIC KEY-----\n", "") | |
.Replace("\n", ""); | |
} | |
if(type == "private") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void KeyExchange() | |
{ | |
String publicKeyPem = PlayerPrefs.GetString("clientPublicKey"); | |
if(String.IsNullOrEmpty(publicKeyPem)) | |
{ | |
throw new PlayerPrefsItemNotFoundException("clientPublicKey"); | |
} | |
String EcPublicKeyDerHexStr = EcPemtoDer(publicKeyPem, "public"); | |
String serializedHttpBody = JsonConvert.SerializeObject(EcPublicKeyDerHexStr); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_session_key(self, _salt, shared_secret) -> bytes: | |
return PBKDF2HMAC( | |
algorithm = hashes.SHA256(), | |
length = 32, | |
salt = _salt, | |
iterations = 310000 | |
).derive(shared_secret) |
OlderNewer