GithubHelp home page GithubHelp logo

ooni / oocrypto Goto Github PK

View Code? Open in Web Editor NEW
0.0 7.0 1.0 23.48 MB

Fork of Go crypto/tls with extra patches from the OONI team

Home Page: https://ooni.org

License: Other

Go 92.54% Assembly 7.38% Shell 0.08%

oocrypto's Introduction

github.com/ooni/oocrypto

This repository contains a fork of a subset of the Go stdlib's crypto package including patches to allow selecting AES hardware support on Android devices. We documented why we need these patches at OONI in the Making the OONI Probe Android app more resilient blog post.

Motivation and maintenance

To solve our issues with Android apps, we originally forked golang/go itself at ooni/go. However, a full fork of Go required us to compile this fork and build Android apps using it, which was making building OONI excessively complicated. Hence, we later chose to just fork the crypto package and documented our efforts at ooni/probe#2106. We will continue to keep this fork up to date as long as it serves our goals.

Intended usage

You SHOULD use this package with the exact Go version from which we extracted the source, which is documented in the Update procedure section. The standard library is composed of tightly integrated packages, hence using this code with another Go version could cause subtle security issues.

The tls/stdlibwrapper.go file contains an API that allows converting code using crypto/tls to code using this package.

func NewClientConnStdlib(conn net.Conn, config *stdlibtls.Config) (*ConnStdlib, error)

The NewClientConnStdlib creates a new client conn taking in input a tls.Config struct as exposed by the stdlib crypto/tls package. The function returns error if you passed in config fields that we don't know (yet?) how to convert from their stdlib definition to the equivalent definition of Config implemented by this module.

The returned ConnStdlib type implements the following interface, which is equivalent to oohttp's TLSConn:

import (
    "context"
    "crypto/tls"
)

type TLSConn interface {
    net.Conn

    HandshakeContext(ctx context.Context) error

    ConnectionState() tls.ConnectionState

    NetConn() net.Conn
}

These changes are sufficient for OONI to use this library instead of using crypto/tls as the underlying TLS library.

License

Each individual file from the crypto fork maintains its original copyright and license. Any change to such files authored by us keeps the same 3-clause BSD license of the original code. Because we anticipate integrating code under the GPL license from Yawning/utls we chose to license the repository using the GPL.

SPDX-License-Identifier: GPL-3.0-or-later

Issue tracker

Please, report issues in the ooni/probe repository. Make sure you mention oocrypto in the issue title.

Patches

Commit 1137f34 merged go1.17.10 src/crypto's subtree into this repository.

Subsequent commits removed unused code and established a procedure to sync with upstream. As part of these commits, we replaced internal/cpu with golang.org/x/sys/cpu.

Finally, we landed patches to improve hardware capability detection on android/arm64.

Update procedure

(Adapted from ooni/oohttp instructions.)

  • check whether hardware capability detection has been improved upstream by reading os_linux.go and update the link to os_linux.go based on the upstream version that we're tracking with this fork

  • update UPSTREAM, commit the change, and then run the ./tools/merge.bash script to merge from upstream;

  • fix all the likely merge conflicts

  • delete all the new packages we can safely delete. We can safely delete a package if the package is not tls and:

  1. either the package does not depend on internal/cpu

  2. or the documentation of the package does not explicitly state that the package is only secure depending on the CPU configuration, which currently only holds for aes (see aes/const.go)

  • ensure that every forked package is never imported by using the following checks (we could also use go list as follows GOOS=os GOARCH=arch go list --json ./...):
  1. git grep 'subtle"'

  2. git grep 'tls"'

  3. git grep 'aes"'

  4. git grep 'alias"'

  5. git grep 'boring"'

  • double check whether we need to add more checks to the list above (you can get a list of packages using tree -d)

  • ensure that stdlibwrapper.go correctly fills tls.ConnectionState in the ConnStdlib.ConnectionState method

  • use ./tools/compare.bash to make sure the changes with respect to upstream are reasonable

  • go build -v ./... must succeed

  • go test -race ./... must succeed

  • run go get -u -v ./... && go mod tidy

  • open a pull request using this check-list as its content and merge it preserving history

oocrypto's People

Contributors

agl avatar bassosimone avatar bradfitz avatar cherrymui avatar cixtor avatar cuishuang avatar cuiweixie avatar dmitshur avatar filosottile avatar ianlancetaylor avatar johanbrandhorst avatar josharian avatar katiehockman avatar kevinburke avatar laboger avatar martisch avatar mundaym avatar mvdan avatar odeke-em avatar pmur avatar randall77 avatar robpike avatar rolandshoemaker avatar rsc avatar stemar94 avatar tklauser avatar tocarip avatar vanbroup avatar vkrasnov avatar zx2c4 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

ainghazal

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.