23 lines
417 B
Go
23 lines
417 B
Go
package unicom
|
|
|
|
import (
|
|
"math/big"
|
|
"testing"
|
|
)
|
|
|
|
func TestEncryptPasswordPacksLittleEndian(t *testing.T) {
|
|
modulus := "10001"
|
|
exponent := "11"
|
|
got, err := encryptPassword(exponent, modulus, "A")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
m := big.NewInt(65537)
|
|
e := big.NewInt(17)
|
|
block := big.NewInt(65)
|
|
want := hexBlock(new(big.Int).Exp(block, e, m))
|
|
if got != want {
|
|
t.Fatalf("got %s want %s", got, want)
|
|
}
|
|
}
|