1//
2// Copyright (c) 2018, Joyent, Inc. All rights reserved.
3//
4// This Source Code Form is subject to the terms of the Mozilla Public
5// License, v. 2.0. If a copy of the MPL was not distributed with this
6// file, You can obtain one at http://mozilla.org/MPL/2.0/.
7//
8
9package authentication
10
11import (
12	"fmt"
13	"regexp"
14)
15
16type httpAuthSignature interface {
17	SignatureType() string
18	String() string
19}
20
21func keyFormatToKeyType(keyFormat string) (string, error) {
22	if keyFormat == "ssh-rsa" {
23		return "rsa", nil
24	}
25
26	if keyFormat == "ssh-ed25519" {
27		return "ed25519", nil
28	}
29
30	if regexp.MustCompile("^ecdsa-sha2-*").Match([]byte(keyFormat)) {
31		return "ecdsa", nil
32	}
33
34	return "", fmt.Errorf("Unknown key format: %s", keyFormat)
35}
36