From e9dd80f9717d405f7e4a3bc6314a1d4f4b2483de Mon Sep 17 00:00:00 2001 From: MrMelon54 Date: Fri, 8 Sep 2023 12:34:31 +0100 Subject: [PATCH] Heavy project cleanup --- .gitignore | 3 +-- .travis.yml | 12 ---------- Godeps/Godeps.json | 59 ---------------------------------------------- Godeps/Readme | 5 ---- README.md | 15 +++++------- doc.go | 2 +- glide.lock | 26 -------------------- glide.yaml | 24 ------------------- go.mod | 10 +++----- go.sum | 6 ++--- totp.go | 4 ++-- totp_test.go | 6 ++--- 12 files changed, 18 insertions(+), 154 deletions(-) delete mode 100644 .travis.yml delete mode 100644 Godeps/Godeps.json delete mode 100644 Godeps/Readme delete mode 100644 glide.lock delete mode 100644 glide.yaml diff --git a/.gitignore b/.gitignore index 81b7ed2..9f11b75 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -keys/ -vendor/ +.idea/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6bbaab4..0000000 --- a/.travis.yml +++ /dev/null @@ -1,12 +0,0 @@ -language: go - -go: - - 1.6.2 - -install: - - go get "github.com/sec51/qrcode" - - go get "github.com/sec51/cryptoengine" - - go get "github.com/sec51/convert/smallendian" - -script: - - go test -v ./... diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json deleted file mode 100644 index cdf2f68..0000000 --- a/Godeps/Godeps.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "ImportPath": "github.com/sec51/twofactor", - "GoVersion": "go1.6", - "GodepVersion": "v74", - "Deps": [ - { - "ImportPath": "github.com/sec51/convert", - "Rev": "8ed1f399b5e0a9a9620c74cfd5aec3682d8328ab" - }, - { - "ImportPath": "github.com/sec51/convert/bigendian", - "Rev": "8ed1f399b5e0a9a9620c74cfd5aec3682d8328ab" - }, - { - "ImportPath": "github.com/sec51/convert/smallendian", - "Rev": "8ed1f399b5e0a9a9620c74cfd5aec3682d8328ab" - }, - { - "ImportPath": "github.com/sec51/cryptoengine", - "Rev": "11617a465c082a1e82359b3c059f018f8dcbfc93" - }, - { - "ImportPath": "github.com/sec51/gf256", - "Rev": "2454accbeb9e6b0e2e53b01e1d641c7157251ed4" - }, - { - "ImportPath": "github.com/sec51/qrcode", - "Rev": "b7779abbcaf1ec4de65f586a85fe24db31d45e7c" - }, - { - "ImportPath": "github.com/sec51/qrcode/coding", - "Rev": "b7779abbcaf1ec4de65f586a85fe24db31d45e7c" - }, - { - "ImportPath": "golang.org/x/crypto/curve25519", - "Rev": "beef0f4390813b96e8e68fd78570396d0f4751fc" - }, - { - "ImportPath": "golang.org/x/crypto/hkdf", - "Rev": "beef0f4390813b96e8e68fd78570396d0f4751fc" - }, - { - "ImportPath": "golang.org/x/crypto/nacl/box", - "Rev": "beef0f4390813b96e8e68fd78570396d0f4751fc" - }, - { - "ImportPath": "golang.org/x/crypto/nacl/secretbox", - "Rev": "beef0f4390813b96e8e68fd78570396d0f4751fc" - }, - { - "ImportPath": "golang.org/x/crypto/poly1305", - "Rev": "beef0f4390813b96e8e68fd78570396d0f4751fc" - }, - { - "ImportPath": "golang.org/x/crypto/salsa20/salsa", - "Rev": "beef0f4390813b96e8e68fd78570396d0f4751fc" - } - ] -} diff --git a/Godeps/Readme b/Godeps/Readme deleted file mode 100644 index 4cdaa53..0000000 --- a/Godeps/Readme +++ /dev/null @@ -1,5 +0,0 @@ -This directory tree is generated automatically by godep. - -Please do not edit. - -See https://github.com/tools/godep for more information. diff --git a/README.md b/README.md index 7aa61ac..ca3a521 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ #### Current test status -[![Build Status](https://travis-ci.org/sec51/twofactor.svg?branch=master)](https://travis-ci.org/sec51/twofactor.svg?branch=master) -[![GoDoc](https://godoc.org/github.com/golang/gddo?status.svg)](https://godoc.org/github.com/sec51/twofactor/) +[![GoDoc](https://godoc.org/github.com/golang/gddo?status.svg)](https://godoc.org/github.com/1f349/twofactor/) ## `totp` @@ -9,14 +8,12 @@ This package implements the RFC 6238 OATH-TOTP algorithm; ### Installation -```go get github.com/sec51/twofactor``` +```go get github.com/1f349/twofactor``` ### Features * Built-in support for secure crypto keys generation -* Built in encryption of the secret keys when converted to bytes, so that they can be safely transmitted over the network, or stored in a DB - * Built-in back-off time when a user fails to authenticate more than 3 times * Bult-in serialization and deserialization to store the one time token struct in a persistence layer @@ -43,9 +40,9 @@ You can then retrieve the object back with the function: `TOTPFromBytes` > You can transfer the bytes securely via a network connection (Ex. if the database is in a different server) because they are encrypted and authenticated. -The struct needs to be stored in a persistent layer becase its values, like last token verification time, +The struct needs to be stored in a persistent layer because its values, like last token verification time, max user authentication failures, etc.. need to be preserved. -The secret key needs to be preserved too, between the user accound and the user device. +The secret key needs to be preserved too, between the user account and the user device. The secret key is in fact used to derive tokens. ### Upcoming features @@ -64,7 +61,7 @@ The secret key is in fact used to derive tokens. 1- Import the library ``` -import github.com/sec51/twofactor +import github.com/1f349/twofactor ``` 2- Instanciate the `totp` object via: @@ -128,7 +125,7 @@ fmt.Printf("OTP: %v\n", otp) ### Author -Initialliy `totp` was written by Sec51 and the further development was made by dnnspaul . +Initialliy `totp` was written by Sec51 and the further development was made by dnnspaul and 1f349. ### License diff --git a/doc.go b/doc.go index c2ef59d..5c23d72 100644 --- a/doc.go +++ b/doc.go @@ -1,5 +1,5 @@ /* -The package twofactor implements the RFC 6238 TOTP: Time-Based One-Time Password Algorithm +Package twofactor implements the RFC 6238 TOTP: Time-Based One-Time Password Algorithm The library provides a simple and secure way to generate and verify the OTP tokens and provides the possibility to display QR codes out of the box diff --git a/glide.lock b/glide.lock deleted file mode 100644 index 850f031..0000000 --- a/glide.lock +++ /dev/null @@ -1,26 +0,0 @@ -hash: edc113943b5834aa52876ee0bdeac172678a94416ed1f3ed8da78afbff402d89 -updated: 2018-09-11T13:25:32.886071+02:00 -imports: -- name: github.com/sec51/convert - version: 3276ac712ca35cb9cc9a823b564fdaf89f4ac803 - subpackages: - - bigendian - - smallendian -- name: github.com/sec51/cryptoengine - version: 2306d105a49ec564d9d376570a1881d557fc4a82 -- name: github.com/sec51/gf256 - version: 2454accbeb9e6b0e2e53b01e1d641c7157251ed4 -- name: github.com/sec51/qrcode - version: b7779abbcaf1ec4de65f586a85fe24db31d45e7c - subpackages: - - coding -- name: golang.org/x/crypto - version: beef0f4390813b96e8e68fd78570396d0f4751fc - subpackages: - - curve25519 - - hkdf - - nacl/box - - nacl/secretbox - - poly1305 - - salsa20/salsa -testImports: [] diff --git a/glide.yaml b/glide.yaml deleted file mode 100644 index ba435ae..0000000 --- a/glide.yaml +++ /dev/null @@ -1,24 +0,0 @@ -package: github.com/sec51/twofactor -import: -- package: github.com/sec51/convert - version: 1.0.1 - subpackages: - - bigendian - - smallendian -- package: github.com/sec51/cryptoengine - version: 0.0.1 -- package: github.com/sec51/gf256 - version: 2454accbeb9e6b0e2e53b01e1d641c7157251ed4 -- package: github.com/sec51/qrcode - version: b7779abbcaf1ec4de65f586a85fe24db31d45e7c - subpackages: - - coding -- package: golang.org/x/crypto - version: beef0f4390813b96e8e68fd78570396d0f4751fc - subpackages: - - curve25519 - - hkdf - - nacl/box - - nacl/secretbox - - poly1305 - - salsa20/salsa diff --git a/go.mod b/go.mod index 0f8c4e3..9bf279d 100644 --- a/go.mod +++ b/go.mod @@ -1,14 +1,10 @@ -module github.com/dnnspaul/twofactor +module github.com/1f349/twofactor go 1.18 require ( - github.com/sec51/convert v0.0.0-20151121170152-8ed1f399b5e0 - github.com/sec51/cryptoengine v0.0.0-20161018113558-11617a465c08 + github.com/sec51/convert v1.0.2 github.com/sec51/qrcode v0.0.0-20160126144534-b7779abbcaf1 ) -require ( - github.com/sec51/gf256 v0.0.0-20160126143050-2454accbeb9e // indirect - golang.org/x/crypto v0.0.0-20151120201419-beef0f439081 // indirect -) +require github.com/sec51/gf256 v0.0.0-20160126143050-2454accbeb9e // indirect diff --git a/go.sum b/go.sum index 8401f8f..15f3650 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,8 @@ github.com/sec51/convert v0.0.0-20151121170152-8ed1f399b5e0 h1:c+Ffq3ZiES6G1HFtiYB1lmLsp5I721z0yAb4SivmjVA= github.com/sec51/convert v0.0.0-20151121170152-8ed1f399b5e0/go.mod h1:SRX4rc9r9AHj56zHfvY1XBPwhLU0vFZdIX7HaD1C3z8= -github.com/sec51/cryptoengine v0.0.0-20161018113558-11617a465c08 h1:S5PhXqtRVsYAocJg3Pgyz2028MDXWL+xognhmlA+lvI= -github.com/sec51/cryptoengine v0.0.0-20161018113558-11617a465c08/go.mod h1:g7izN9sUffTPdvcrt39y/ZephG5oJ9XizhJxxBOYDL0= +github.com/sec51/convert v1.0.2 h1:NoKWIRARjM3rQglNypMpcXSLLqPsN/uTTzaGeqDKbeg= +github.com/sec51/convert v1.0.2/go.mod h1:5qL/cT/oiOIvWXy2SccQ7LnacYftqqy9wdyFkTc1k2w= github.com/sec51/gf256 v0.0.0-20160126143050-2454accbeb9e h1:wKXba8dfsFjbxkMpzZBKt8gkJAMSm1fIf1OSWQFQrVA= github.com/sec51/gf256 v0.0.0-20160126143050-2454accbeb9e/go.mod h1:hCjOqSOB9PBw5MdJ+0uSLCBV7FbLy0xwOR+c193HkcE= github.com/sec51/qrcode v0.0.0-20160126144534-b7779abbcaf1 h1:CI9zS8HvMiibvXM/F3IthY797GW77fNYgioJl/8Xzzk= github.com/sec51/qrcode v0.0.0-20160126144534-b7779abbcaf1/go.mod h1:uPm44Rj3uXSSOvmKmoeRuAUNUgwH2JHW5KIzqFFS/j4= -golang.org/x/crypto v0.0.0-20151120201419-beef0f439081 h1:Pmlkv+UkNMx18O/oeAbr4BQZSewYOl1jsf8k7K1cbu4= -golang.org/x/crypto v0.0.0-20151120201419-beef0f439081/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= diff --git a/totp.go b/totp.go index 266ff3f..ba2dddf 100644 --- a/totp.go +++ b/totp.go @@ -292,7 +292,7 @@ func (otp *Totp) Secret() string { // URL returns a suitable URL, such as for the Google Authenticator app // example: otpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Example -func (otp *Totp) url() (string, error) { +func (otp *Totp) URL() (string, error) { // verify the proper initialization if err := totpHasBeenInitialized(otp); err != nil { @@ -333,7 +333,7 @@ func (otp *Totp) url() (string, error) { func (otp *Totp) QR() ([]byte, error) { // get the URL - u, err := otp.url() + u, err := otp.URL() // check for errors during initialization // this is already done on the URL method diff --git a/totp_test.go b/totp_test.go index c4112a5..9cbdc3d 100644 --- a/totp_test.go +++ b/totp_test.go @@ -308,12 +308,12 @@ func TestSerialization(t *testing.T) { t.Error("Deserialized hash property differ from original TOTP") } - deserializedUrl, err := deserializedOTP.url() + deserializedUrl, err := deserializedOTP.URL() if err != nil { t.Error(err) } - otpdUrl, err := otp.url() + otpdUrl, err := otp.URL() if err != nil { t.Error(err) } @@ -342,7 +342,7 @@ func TestSerialization(t *testing.T) { func TestProperInitialization(t *testing.T) { otp := Totp{} - if _, err := otp.url(); err == nil { + if _, err := otp.URL(); err == nil { t.Fatal("Totp is not properly initialized and the method did not catch it") } }