All Projects → amoghe → go-crypt

amoghe / go-crypt

Licence: MIT license
Golang wrappers for glibc crypt(3)

Programming Languages

go
31211 projects - #10 most used programming language

Labels

Projects that are alternatives of or similar to go-crypt

Libmemory
Embedded systems memory management library. Implementations for malloc(), free(), and other useful memory management functions
Stars: ✭ 102 (+183.33%)
Mutual labels:  libc
Melvix
💻 A small operating system written from scratch
Stars: ✭ 69 (+91.67%)
Mutual labels:  libc
minilib
A c standard system library with a focus on size, headeronly, "singlefile", intended for static linking. 187 Bytes for "Hello World"(regular elf), compiled with the standard gcc toolchain.
Stars: ✭ 29 (-19.44%)
Mutual labels:  libc
Search Libc
Web wrapper of niklasb/libc-database
Stars: ✭ 124 (+244.44%)
Mutual labels:  libc
Bdvl
LD_PRELOAD Linux rootkit (x86 & ARM)
Stars: ✭ 232 (+544.44%)
Mutual labels:  libc
platform bionic
Hardened Android standard C library. Some of the past hardening has not yet been ported from Marshmallow, Nougat and Oreo to this Android Pie repository. Most is available via archived tags in https://github.com/AndroidHardeningArchive/platform_bionic (check both the most recent Oreo and Nougat tags).
Stars: ✭ 66 (+83.33%)
Mutual labels:  libc
One gadget
The best tool for finding one gadget RCE in libc.so.6
Stars: ✭ 1,306 (+3527.78%)
Mutual labels:  libc
crystal-autobind
Automatic C bindings generator for Crystal
Stars: ✭ 15 (-58.33%)
Mutual labels:  libc
readhook
Red-team tool to hook libc read syscall with a buffer overflow vulnerability.
Stars: ✭ 31 (-13.89%)
Mutual labels:  libc
ghidra-findcrypt
Ghidra analysis plugin to locate cryptographic constants
Stars: ✭ 138 (+283.33%)
Mutual labels:  crypt
C standard lib
source code of The Standard C Library, by Plauger
Stars: ✭ 133 (+269.44%)
Mutual labels:  libc
Libc
libc targeted for embedded systems usage. Reduced set of functionality (due to embedded nature). Chosen for portability and quick bringup.
Stars: ✭ 224 (+522.22%)
Mutual labels:  libc
Aqeous
(Inactive, Checkout AvanaOS, Rewrite of this) This is a New Operating System (Kernel right now). Made completely from scratch, We aim to make a complete OS for Learning purpose
Stars: ✭ 23 (-36.11%)
Mutual labels:  libc
Nix
Rust friendly bindings to *nix APIs
Stars: ✭ 1,660 (+4511.11%)
Mutual labels:  libc
libc
KnightOS's C library
Stars: ✭ 30 (-16.67%)
Mutual labels:  libc
Monkos
an experimental 64-bit operating system
Stars: ✭ 100 (+177.78%)
Mutual labels:  libc
Berserker
Obfuscate your Python scripts better, faster.
Stars: ✭ 81 (+125%)
Mutual labels:  crypt
libc-db
libc database (file in packages, hash, package files, symbols). Raw binary libc available on https://github.com/BestPig/libc-bin)
Stars: ✭ 21 (-41.67%)
Mutual labels:  libc
wcwidth
A Unicode 13-conformant implementation of wcwidth() in C.
Stars: ✭ 28 (-22.22%)
Mutual labels:  libc
connect
tiny cross-platform socket API library
Stars: ✭ 46 (+27.78%)
Mutual labels:  libc

go-crypt (crypt)

Build Status

Package crypt provides go language wrappers around crypt(3). For further information on crypt see the man page

If you have questions about how to use crypt (the C function), it is likely this is not the package you are looking for.

NOTE Depending on the platform, this package provides a Crypt function that is backed by different flavors of the libc crypt. This is done by detecting the GOOS and trying to build using crypt_r (the GNU extension) when on linux, and wrapping around plain 'ol crypt (guarded by a global lock) otherwise.

Example

import (
	"fmt"
	"github.com/amoghe/go-crypt"
)

func main() {
	md5, err := crypt.Crypt("password", "in")
	if err != nil {
		fmt.Errorf("error:", err)
		return
	}

	sha512, err := crypt.Crypt("password", "$6$SomeSaltSomePepper$")
	if err != nil {
		fmt.Errorf("error:", err)
		return
	}

	fmt.Println("MD5:", md5)
	fmt.Println("SHA512:", sha512)
}

A Note On "Salt"

You can find out more about salt here

The hash algorithm can be selected via the salt string. Here is how to do it (relevant section from the man page):

   If salt is a character string starting with the characters
   "$id$" followed by a string terminated by "$":

       $id$salt$encrypted

   then instead of using the DES machine, id identifies the
   encryption method used and this then determines how the rest
   of the password string is interpreted.  The following values
   of id are supported:

          ID  | Method
          ─────────────────────────────────────────────────────────
          1   | MD5
          2a  | Blowfish (not in mainline glibc; added in some
              | Linux distributions)
          5   | SHA-256 (since glibc 2.7)
          6   | SHA-512 (since glibc 2.7)

   So $5$salt$encrypted is an SHA-256 encoded password and
   $6$salt$encrypted is an SHA-512 encoded one.

   "salt" stands for the up to 16 characters following "$id$" in
   the salt.  The encrypted part of the password string is the
   actual computed password.  The size of this string is fixed:

   MD5     | 22 characters
   SHA-256 | 43 characters
   SHA-512 | 86 characters

Platforms

This package has been tested on the following platforms:

  • ubuntu 14.04.2 (libc 2.19)
  • ubuntu 12.04.5 (libc 2.15)
  • centos (libc 2.17)
  • fedora 22 (libc 2.21)

All the platforms tested on have GNU libc (with extensions) so that the GOOS=linux always compiles the reentrant versions of the crypt function (crypt_r), and exposes it to go land.

Other platforms (freebsd, netbsd) should also work (in theory) since their libc expose at least a posix compliant crypt function. On these platforms the fallback should compile and expose the 'plain' (non reentrant, thus globally locked) crypt function.

Unfortunately, I do not have access to machines that run anything other than Linux, hence the other platforms have not been tested, however I believe they should work just fine. If you can verify this (or provide a patch that fixes this), I would be grateful.

TODO

  • Find someone with access to *BSD system(s)

License

Released under the MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].