protocol formatting test

other stuff too
This commit is contained in:
Malloc of Kuzkycyziklistan 2017-05-18 09:00:15 -05:00
parent 3fb9399440
commit c8bb3ceafd
6 changed files with 15 additions and 9 deletions

View file

@ -34,10 +34,14 @@ All numbers, unless otherwise specified, are the string representation of a base
#### Server to Client
0. Login/registration request.
0. Diffie-Hellman key exchange
| Region | | | Length |
| ------ | --- | --- | ------ |
| test | a | b | c |
#### Client to Server
0. Diffie-Hellman key exchange
## Sockstamps

View file

@ -32,7 +32,5 @@ namespace CircleScape.Encryption {
cipher[x] = state[(state[i] + state[j]) % 256];
}
}
// http://bradconte.com/rc4_c
}
}

View file

@ -4,14 +4,18 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
using Square;
namespace CircleScape.Encryption {
class KeyExchange {
private BigInteger Secret;
public BigInteger Generator { get; private set; }
public BigInteger Generator { get; private set; } = 2;
public BigInteger Modulus { get; private set; }
public BigInteger PrivateKey { get; private set; }
public BigInteger PrivateKey { get; private set; } = BigInteger.MinusOne;
// https://security.stackexchange.com/questions/45963/diffie-hellman-key-exchange-in-plain-english/45971#45971
public KeyExchange() {
Secret = RNG.NextPrime(512 / 8);
Modulus = RNG.NextPrime(512 / 8);
}
}
}

View file

@ -11,7 +11,7 @@ using Square;
namespace CircleScape {
class Entrypoint {
static void Main(string[] args) {
var a = Square.Random.NextPrime(512 / 8);
var a = Square.RNG.NextPrime(512 / 8);
Console.WriteLine(a.ToString("X"));
var server = new Kneesocks.Server<PendingConnection>(6770, PoolManager.Pending);

View file

@ -56,7 +56,7 @@ namespace Square {
if(absValue < 25) return true;
for(var i = 0; i < iterations; ++i) {
var rand = Random.NextBigInt(2, absValue - 2);
var rand = RNG.NextBigInt(2, absValue - 2);
if(!BigInteger.ModPow(rand, absValue - 1, absValue).IsOne) return false;
}

View file

@ -6,7 +6,7 @@ using System.Threading.Tasks;
using System.Numerics;
namespace Square {
public static class Random {
public static class RNG {
private static System.Random RandCtx = new System.Random();
public static int Next() {