2016-02-01 01:56:10 -08:00
|
|
|
package common
|
|
|
|
|
2016-02-15 00:34:29 -08:00
|
|
|
/*
|
|
|
|
I2P RouterIdentity
|
2016-06-16 23:17:21 -07:00
|
|
|
https://geti2p.net/spec/common-structures#routeridentity
|
2016-02-15 00:34:29 -08:00
|
|
|
Accurate for version 0.9.24
|
|
|
|
|
|
|
|
Identical to KeysAndCert
|
|
|
|
*/
|
|
|
|
|
2016-02-01 01:56:10 -08:00
|
|
|
import (
|
2022-05-22 19:59:20 -04:00
|
|
|
. "github.com/go-i2p/go-i2p/lib/common/certificate"
|
|
|
|
. "github.com/go-i2p/go-i2p/lib/common/keys_and_cert"
|
|
|
|
|
2021-04-19 20:43:37 -04:00
|
|
|
"github.com/go-i2p/go-i2p/lib/crypto"
|
2016-02-01 01:56:10 -08:00
|
|
|
)
|
|
|
|
|
2016-02-15 00:34:29 -08:00
|
|
|
//
|
|
|
|
// A RouterIdentity is identical to KeysAndCert.
|
|
|
|
//
|
2022-05-09 20:43:24 -04:00
|
|
|
type RouterIdentity struct {
|
|
|
|
KeysAndCert *KeysAndCert
|
|
|
|
}
|
|
|
|
|
|
|
|
//[]byte
|
2016-02-01 01:56:10 -08:00
|
|
|
|
2022-05-09 20:43:24 -04:00
|
|
|
func (router_identity *RouterIdentity) PublicKey() crypto.PublicKey {
|
|
|
|
return router_identity.KeysAndCert.PublicKey()
|
2016-02-01 01:56:10 -08:00
|
|
|
}
|
|
|
|
|
2022-05-09 20:43:24 -04:00
|
|
|
func (router_identity *RouterIdentity) SigningPublicKey() crypto.SigningPublicKey {
|
|
|
|
return router_identity.KeysAndCert.SigningPublicKey()
|
2016-02-01 01:56:10 -08:00
|
|
|
}
|
|
|
|
|
2022-05-09 20:43:24 -04:00
|
|
|
func (router_identity *RouterIdentity) Certificate() *Certificate {
|
|
|
|
return router_identity.KeysAndCert.Certificate()
|
2016-02-01 01:56:10 -08:00
|
|
|
}
|
|
|
|
|
2016-02-15 00:34:29 -08:00
|
|
|
func ReadRouterIdentity(data []byte) (router_identity RouterIdentity, remainder []byte, err error) {
|
2022-05-09 20:43:24 -04:00
|
|
|
keys_and_cert, remainder, err := NewKeysAndCert(data)
|
|
|
|
router_identity = RouterIdentity{
|
|
|
|
KeysAndCert: keys_and_cert,
|
|
|
|
} //(keys_and_cert)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewRouterIdentity(data []byte) (router_identity *RouterIdentity, remainder []byte, err error) {
|
|
|
|
objrouter_identity, remainder, err := ReadRouterIdentity(data)
|
|
|
|
router_identity = &objrouter_identity
|
2016-02-15 00:34:29 -08:00
|
|
|
return
|
2016-02-01 01:56:10 -08:00
|
|
|
}
|