Heavy project cleanup

This commit is contained in:
Melon 2023-09-08 12:34:31 +01:00
parent dc592e013f
commit e9dd80f971
Signed by: melon
GPG Key ID: 6C9D970C50D26A25
12 changed files with 18 additions and 154 deletions

3
.gitignore vendored
View File

@ -1,2 +1 @@
keys/
vendor/
.idea/

View File

@ -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 ./...

59
Godeps/Godeps.json generated
View File

@ -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"
}
]
}

5
Godeps/Readme generated
View File

@ -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.

View File

@ -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 <info@sec51.com> and the further development was made by dnnspaul <dennis@blaumedia.com>.
Initialliy `totp` was written by Sec51 <info@sec51.com> and the further development was made by dnnspaul <dennis@blaumedia.com> and 1f349.
### License

2
doc.go
View File

@ -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

26
glide.lock generated
View File

@ -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: []

View File

@ -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

10
go.mod
View File

@ -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

6
go.sum
View File

@ -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=

View File

@ -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

View File

@ -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")
}
}