Esempio n. 1
0
func DecryptAndGunzip(dstfile, srcfile string, key, iv []byte) {
	f, _ := os.Open(srcfile, os.O_RDONLY, 0)
	defer f.Close()
	c, _ := aes.NewCipher(key)
	r := block.NewOFBReader(c, iv, f)
	r, _ = gzip.NewInflater(r)
	w, _ := os.Open(dstfile, os.O_WRONLY|os.O_CREATE, 0666)
	defer w.Close()
	io.Copy(w, r)
}
Esempio n. 2
0
func create_readers(ciphers *[]block.Cipher) *[]io.Reader {
	reader := &NullReaderWriter{}

	// ECB, CBC, CTR, OFB ...?
	readers := make([]io.Reader, len(*ciphers)*4)

	for i, cipher := range *ciphers {

		readers[i] = block.NewECBDecrypter(cipher, io.LimitReader(reader, 1024*1024*16))
		readers[i+len(*ciphers)] = block.NewCBCDecrypter(cipher, gen_iv(cipher), io.LimitReader(reader, 1024*1024*16))
		readers[i+2*len(*ciphers)] = block.NewCTRReader(cipher, gen_iv(cipher), io.LimitReader(reader, 1024*1024*16))
		readers[i+3*len(*ciphers)] = block.NewOFBReader(cipher, gen_iv(cipher), io.LimitReader(reader, 1024*1024*16))

	}
	return &readers
}