Giter Site home page Giter Site logo

drr00t / tweetnacl-cs Goto Github PK

View Code? Open in Web Editor NEW
13.0 2.0 6.0 8.07 MB

A 100% native C# implementation of TweetNaCl for .NET

License: Mozilla Public License 2.0

C# 97.17% Batchfile 0.67% F# 1.36% Shell 0.61% Dockerfile 0.19%
nacl tweetnacl encryption ed25519 secretkey publickey secretbox cryptobox signature scalar-multiplication

tweetnacl-cs's Introduction

#TweetNaCl-cs

Branch Build Code Cover
master .Net Build status
Mono Build Status
Coveralls Coverage Status

About Project

A C# port of original TweetNaCl C language implementation version 20140427.

⚠️ The library is not stable yet and API will change and was not independently reviewed. If you can help reviewing it, please [contact me](mailto:adribeiro (at) gmail.com).

##Documentation

Public-key authenticated encryption (box)

Implements curve25519-xsalsa20-poly1305.

Byte[] CryptoBoxKeypair(Byte[] secretKey)

The CryptoBoxKeypair function randomly generates a secretKey and a corresponding public key. The secretKey array must have size equal to crypto_box_SECRETKEYBYTES

Byte[] CryptoBox(Byte[] message, Byte[] nonce, Byte[] publicKey, Byte[] secretKey)

The function encrypts and authenticates a message using the nonce, receiver´s publicKey and sender´s secretKey.

Byte[] CryptoBoxOpen(Byte[] cipheredMessage, Byte[] nonce, Byte[] publicKey, Byte[] secretKey)

The function verifies and decrypts a cipherMessage using the receiver's secretKey, the sender's publicKey, and a nonce.

Byte[] CryptoBoxBeforenm(Byte[] publicKey, Byte[] secretKey)

Applications that send several messages to the same receiver can gain speed by splitting CryptoBox into two steps, CryptoBoxBeforenm and CryptoBoxAfternm.

Byte[] CryptoBoxAfternm(Byte[] message, Byte[] nonce, Byte[] k)

Byte[] CryptoBoxOpenAfternm(Byte[] cipheredMessage, Byte[] nonce, Byte[] k)

Byte[] CryptoSignKeypair(Byte[] secretKey)

Byte[] CryptoSign(Byte[] message, Byte[] secretKey)

Byte[] CryptoSignOpen(Byte[] signedMessage, Byte[] publicKey)

Byte[] CryptoScalarmult(Byte[] n, Byte[] p)

Scalar multiplication is a curve25519 implementation.

Byte[] CryptoScalarmultBase(Byte[] n)

The CryptoScalarmultBase function computes the scalar product of a standard group element and an integer n

##Third-party libraries

##Who is using

##License This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

tweetnacl-cs's People

Contributors

drr00t avatar leandrogm avatar zamabraga avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tweetnacl-cs's Issues

CryptoHash result differs from SHA512

The implementation of CryptoHash contains a bug for larger messages.

    public void TestHash512Check()
    {
        // Setup
        var message = new byte[]
        {
            0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
            0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
            0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
            0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
            0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
            0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
            0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
        };
        var output = new byte[64];

        // Test
        TweetNaCl.TweetNaCl.CryptoHash(output, message, message.Length);

        // Check
        byte[] check;
        using (var sha512 = SHA512.Create())
        {
            check = sha512.ComputeHash(message);
        }
        Assert.Equal(check, output);
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.