func main() { defaultRootPassword := defs.RootUserName secureKeyFileNamePath := flag.String("secure-key", "./secureKey", "secure key file path") loginFilePath := flag.String("storage-file", "./data.txt", "First storage file that includes the root user") rootPassword := flag.String("password", defaultRootPassword, "Root password") str := fmt.Sprintf("Generate RSA private/public files ('%s', '%s')", rsaPrivateKeyFileName, rsaPublicKeyFileName) generateRSA := flag.Bool("generate-rsa", false, str) flag.Parse() if flag.NArg() > 0 { usage() } if *rootPassword == defaultRootPassword { fmt.Printf("Error: The root password must be set (and not to '%v')\n", defaultRootPassword) usage() } err := password.CheckPasswordStrength(*rootPassword) if err != nil { log.Fatalf("Error: The root password must be more complex: %v", err) } key := ss.GetSecureKey(*secureKeyFileNamePath) createBasicFile(*loginFilePath, defs.RootUserName, *rootPassword, key) fmt.Println("The generated file name is:", *loginFilePath) if *generateRSA { generateRSAKeys(rsaPrivateKeyFileName, rsaPublicKeyFileName) } }
// NewOtpUser : generate a new otp user with the given parameters func NewOtpUser(secret []byte, checkSecretStrength bool, lock bool, cliffLen int32, thrTimeSec time.Duration, autoUnblockSec time.Duration, hotpWindowSize time.Duration, totpWindowSize time.Duration, startCount int64) (*UserInfoOtp, error) { err := password.CheckPasswordStrength(string(secret)) if err != nil && checkSecretStrength { return nil, err } hotp, err := NewHotp(secret, startCount) if err != nil { return nil, err } totp, err := NewTotp(secret) if err != nil { return nil, err } return &UserInfoOtp{secret, lock, newThrottle(cliffLen, thrTimeSec, autoUnblockSec, hotpWindowSize, totpWindowSize), hotp, totp}, err }