cryptog

package module
v0.0.0-...-7627f76 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2018 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

cryptog

A cryptographic wrapper library for the Go programming language

Synopsis

Implements the RC4 and AES wrapper libraries.

RC4 Wrappers

Each of the RC4 wrappers contain an Initialization Vector (IV) and a constant value that will be checked to maintain data integrity.

RC4_PrepareKey()

This method takes any length key and takes a SHA256 sum of it, making it suitable for the RC4 encrypt/decrypt functions.

func RC4_PrepareKey(key []byte) *[]byte // Return an array containing the SHA256 of the input key

RC4_Encrypt()

This method uses the following structure:

[IV][Constant][Data]

The IV is randomized each time, but if the key is the same, then the Constant should be the same, otherwise the RC4_Decrypt() method will fail.

Please note that if the input_key parameter is nil, then the method will generate its own by calling generateHostnameKey(), which will be a key based on the hostname of the system.

const RC4_IV_LEN uint = 16
var RC4_CONSTANT_VALUE = [4]byte{ 0x40, 0xad, 0x4f, 0x22 }

func RC4_Encrypt(data []byte, input_key *[]byte) ([]byte, error)

RC4_Decrypt()

The decrypt method removes the IV and Constant values, but checks that the Constant matches RC4_CONSTANT_VALUE, otherwise an error will be thrown.

func RC4_Decrypt(data []byte, input_key *[]byte) ([]byte, error)

generateHostnameKey()

This method is used to generate a key based on the hostname of the system. An MD5 sum of the host is taken and returned as a []byte vector.

func generateHostnameKey() []byte

AES Wrappers

//TODO

Documentation

Overview

* Copyright (c) 2017 AlexRuzin (stan.ruzin@gmail.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE.

Index

Constants

View Source
const AES_KEY_SEED string = "b1ec0efec8bf032e586ffd4071b79757"
View Source
const RC4_IV_LEN uint = 16

The default initialization vector length for a new RC4 stream

View Source
const STATUS_FAIL int = -1
View Source
const STATUS_OK int = 0

Variables

View Source
var RC4_CONSTANT_VALUE = [4]byte{0x40, 0xad, 0x4f, 0x22}

Functions

func AES128CBC_Decrypt

func AES128CBC_Decrypt(data []byte, input_key *[]byte) ([]byte, int)

FIXME -- The AES functions are not complete

func AES128CBC_Encrypt

func AES128CBC_Encrypt(data []byte, input_key *[]byte) ([]byte, int)

FIXME -- The AES functions are not complete

func GenerateRSAKeyPair

func GenerateRSAKeyPair(bitsize int) (public []byte, private *rsa.PrivateKey, err error)

func RC4_Decrypt

func RC4_Decrypt(data []byte, input_key *[]byte) ([]byte, error)

func RC4_Encrypt

func RC4_Encrypt(data []byte, input_key *[]byte) ([]byte, error)

func RC4_PrepareKey

func RC4_PrepareKey(key []byte) *[]byte

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址