func CreateMasterKeyObject(ctx context.Context, password []byte) (*primitive.MasterKey, error) {
	m := &primitive.MasterKey{
		Alg: Triplesec,
	}

	// Generate a master key of 256 bytes
	key := make([]byte, masterKeyBytes)
	_, err := rand.Read(key)
	if err != nil {
		return nil, err
	}

	err = ctxutil.ErrIfDone(ctx)
	if err != nil {
		return nil, err
	}

	ts, err := newTriplesec(ctx, password)
	if err != nil {
		return nil, err
	}

	ct, err := ts.Encrypt(key)
	if err != nil {
		return nil, err
	}

	// Encode the master key value to base64url
	m.Value = base64url.NewValue(ct)
	return m, nil
}
// CreateMasterKeyObject generates a 256 byte master key which is then
// encrypted using TripleSec-v3 using the given password.
CreateMasterKeyObject generates a 256 byte master key which is then
encrypted using TripleSec-v3 using the given password.
// CreateMasterKeyObject generates a 256 byte master key which is then // encrypted using TripleSec - v3 using the given password .
func CreateMasterKeyObject(ctx context.Context, password []byte) (*primitive.MasterKey, error) {
	m := &primitive.MasterKey{
		Alg: Triplesec,
	}
	key := make([]byte, masterKeyBytes)
	_, err := rand.Read(key)
	if err != nil {
		return nil, err
	}
	err = ctxutil.ErrIfDone(ctx)
	if err != nil {
		return nil, err
	}
	ts, err := newTriplesec(ctx, password)
	if err != nil {
		return nil, err
	}
	ct, err := ts.Encrypt(key)
	if err != nil {
		return nil, err
	}
	m.Value = base64url.NewValue(ct)
	return m, nil
}
func CreateMasterKeyObject ( ctx context . Context , password [ ] byte ) ( * primitive . MasterKey , error ) { m := & primitive . MasterKey { Alg : Triplesec , } key := make ( [ ] byte , masterKeyBytes ) _ , err := rand . Read ( key ) if err != nil { return nil , err } err = ctxutil . ErrIfDone ( ctx ) if err != nil { return nil , err } ts , err := newTriplesec ( ctx , password ) if err != nil { return nil , err } ct , err := ts . Encrypt ( key ) if err != nil { return nil , err } m . Value = base64url . NewValue ( ct ) return m , nil }
CreateMasterKeyObject generates a 256 byte master key which is then
encrypted using TripleSec-v3 using the given password.
CreateMasterKeyObject generates a 256 byte master key which is then encrypted using TripleSec - v3 using the given password .
// Generate a master key of 256 bytes // Encode the master key value to base64url