X-Git-Url: http://www.git.cypherpunks.ru/?p=govpn.git;a=blobdiff_plain;f=src%2Fcypherpunks.ru%2Fgovpn%2Fencless.go;h=bd42f1d5729349e1a4c3bf6fe2bb813445ee6249;hp=30eb4a5e33d9446f07c646c03bede769c4043339;hb=0bf04621961589bc735dc8bd8a075d7db24c4178;hpb=cecb63f12f4a9f523276a0c19c7feb7437c7f53a diff --git a/src/cypherpunks.ru/govpn/encless.go b/src/cypherpunks.ru/govpn/encless.go index 30eb4a5..bd42f1d 100644 --- a/src/cypherpunks.ru/govpn/encless.go +++ b/src/cypherpunks.ru/govpn/encless.go @@ -19,6 +19,8 @@ along with this program. If not, see . package govpn import ( + "io" + "cypherpunks.ru/govpn/aont" "cypherpunks.ru/govpn/cnw" ) @@ -33,10 +35,10 @@ const ( // encryption nor steganography) over All-Or-Nothing-Transformed data. // nonce is 64-bit nonce. Output data will be EnclessEnlargeSize larger. // It also consumes 64-bits of entropy. -func EnclessEncode(authKey *[32]byte, nonce, in []byte) ([]byte, error) { +func EnclessEncode(authKey *[32]byte, nonce *[16]byte, in []byte) ([]byte, error) { r := new([aont.RSize]byte) var err error - if _, err = Rand.Read(r[:]); err != nil { + if _, err = io.ReadFull(Rand, r[:]); err != nil { return nil, err } aonted, err := aont.Encode(r, in) @@ -44,7 +46,7 @@ func EnclessEncode(authKey *[32]byte, nonce, in []byte) ([]byte, error) { return nil, err } out := append( - cnw.Chaff(authKey, nonce, aonted[:aont.RSize]), + cnw.Chaff(authKey, nonce[8:], aonted[:aont.RSize]), aonted[aont.RSize:]..., ) SliceZero(aonted[:aont.RSize]) @@ -52,10 +54,10 @@ func EnclessEncode(authKey *[32]byte, nonce, in []byte) ([]byte, error) { } // Decode EnclessEncode-ed data. -func EnclessDecode(authKey *[32]byte, nonce, in []byte) ([]byte, error) { +func EnclessDecode(authKey *[32]byte, nonce *[16]byte, in []byte) ([]byte, error) { var err error winnowed, err := cnw.Winnow( - authKey, nonce, in[:aont.RSize*cnw.EnlargeFactor], + authKey, nonce[8:], in[:aont.RSize*cnw.EnlargeFactor], ) if err != nil { return nil, err