GithubHelp home page GithubHelp logo

shahzaibalikhan / go-openssl-shim Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tahirhassan10p/go-openssl-shim-1

0.0 1.0 0.0 92.27 MB

A tiny sample application to run go-openssl-shim across multiple distros.

Makefile 13.65% Go 12.77% Shell 73.58%

go-openssl-shim's Introduction

go-openssl-shim

A tiny sample application to run go-openssl-shim across multiple distros.

Usage

It can be either run with a docker container or directly from an debian based distribution. It supports following docker containers:

  • alpine
  • jessie
  • stretch
  • trusty
  • xenial

Docker

    # build docker image of particular distro
    $ make build DISTRO=jessie # it could be anything
    # run the hello world
    $ make run DISTRO=jessie

Vanilla

To run it without docker, you must have a working golang compiler installed with all its environment variable setup.

    # clone this repository in your $GOPATH
    # setup your system
    $ sudo ./scripts/setup.sh
    # export required environment variables
    $ source srcipts/env.sh
    # run the hello world program
    $ go run main.go

Note

OpenSSL has a method called FIPS_mode_set() that we invoke before execution to enter FIPS mode of operation, if the FIPS Object Module successfully enters FIPS mode, the function will return that non-zero value and a power-up self-test is performed automatically with its call. These self-tests can also be optionally invoked at any time by the FIPS_selftest() call in C code.

Its being done in openssl package as follows:

package openssl

// #cgo pkg-config: openssl
// #cgo LDFLAGS: -lcrypto -ldl
// #cgo CFLAGS: -std=c99
// #include <openssl/err.h>
// #include <openssl/crypto.h>
// #include <stdlib.h>
// extern int FIPS_init(void);
// extern void schedule_thread_cleanup(void);
import "C"
import (
	"log"
	"runtime"
	"strings"
)

func init() {
	runtime.LockOSThread()
	defer runtime.UnlockOSThread()
	if C.FIPS_init() != 1 {
		log.Fatal(GetError())
	}
}

Here C.FIPS_init() is a function that wraps over OpenSSL's FIPS_mode_set() which is being called in init function, so whenever openssl package is included anywhere, it automatically initiates the FIPS mode thus resulting in running all the self-tests.

go-openssl-shim's People

Contributors

umayr avatar

Watchers

Shahzaib Ali Khan avatar

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.