2020-08-10 17:15:02 -04:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
2023-02-02 17:15:17 -08:00
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
|
|
2020-07-29 07:58:19 -04:00
|
|
|
package password
|
|
|
|
|
|
|
|
|
|
import (
|
2023-06-06 17:09:08 -04:00
|
|
|
"context"
|
|
|
|
|
|
2020-08-10 17:15:02 -04:00
|
|
|
"github.com/hashicorp/boundary/internal/db"
|
2021-02-11 13:32:45 -06:00
|
|
|
"github.com/hashicorp/boundary/internal/errors"
|
2020-07-29 07:58:19 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Prefixes for private ids for types in the password package.
|
|
|
|
|
const (
|
|
|
|
|
argon2ConfigurationPrefix = "arg2conf"
|
2020-07-31 11:18:41 -04:00
|
|
|
argon2CredentialPrefix = "arg2cred"
|
2020-07-29 07:58:19 -04:00
|
|
|
)
|
|
|
|
|
|
2023-06-06 17:09:08 -04:00
|
|
|
func newArgon2ConfigurationId(ctx context.Context) (string, error) {
|
2021-02-11 13:32:45 -06:00
|
|
|
const op = "password.newArgon2ConfigurationId"
|
2023-06-06 17:09:08 -04:00
|
|
|
id, err := db.NewPrivateId(ctx, argon2ConfigurationPrefix)
|
2020-07-29 07:58:19 -04:00
|
|
|
if err != nil {
|
2023-06-06 17:09:08 -04:00
|
|
|
return "", errors.Wrap(ctx, err, op)
|
2020-07-29 07:58:19 -04:00
|
|
|
}
|
2021-03-05 06:34:06 -08:00
|
|
|
return id, nil
|
2020-07-29 07:58:19 -04:00
|
|
|
}
|
2020-07-31 11:18:41 -04:00
|
|
|
|
2023-06-06 17:09:08 -04:00
|
|
|
func newArgon2CredentialId(ctx context.Context) (string, error) {
|
2021-02-11 13:32:45 -06:00
|
|
|
const op = "password.newArgon2CredentialId"
|
2023-06-06 17:09:08 -04:00
|
|
|
id, err := db.NewPrivateId(ctx, argon2CredentialPrefix)
|
2020-07-31 11:18:41 -04:00
|
|
|
if err != nil {
|
2023-06-06 17:09:08 -04:00
|
|
|
return "", errors.Wrap(ctx, err, op)
|
2020-07-31 11:18:41 -04:00
|
|
|
}
|
2021-03-05 06:34:06 -08:00
|
|
|
return id, nil
|
2020-07-31 11:18:41 -04:00
|
|
|
}
|