work on leasesets
This commit is contained in:
@ -146,18 +146,6 @@ func ReadKeysAndCert(data []byte) (keys_and_cert KeysAndCert, remainder []byte,
|
|||||||
PublicKey: pk,
|
PublicKey: pk,
|
||||||
Certificate: cert,
|
Certificate: cert,
|
||||||
}
|
}
|
||||||
cert_len, cert_len_err := cert.Length()
|
|
||||||
if cert_len == 0 {
|
|
||||||
remainder = data[KEYS_AND_CERT_MIN_SIZE:]
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if data_len < KEYS_AND_CERT_MIN_SIZE+cert_len {
|
|
||||||
keys_and_cert.Certificate.CertBytes = append(keys_and_cert.Cert(), data[KEYS_AND_CERT_MIN_SIZE:]...)
|
|
||||||
err = cert_len_err
|
|
||||||
} else {
|
|
||||||
keys_and_cert.Certificate.CertBytes = append(keys_and_cert.Cert(), data[KEYS_AND_CERT_MIN_SIZE:KEYS_AND_CERT_MIN_SIZE+cert_len]...)
|
|
||||||
remainder = data[KEYS_AND_CERT_MIN_SIZE+cert_len:]
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,5 +215,17 @@ func ReadKeys(data []byte, cert Certificate) (spk crypto.SigningPublicKey, pk cr
|
|||||||
spk = dsa_pk
|
spk = dsa_pk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
cert_len, cert_len_err := cert.Length()
|
||||||
|
if cert_len == 0 {
|
||||||
|
remainder = data[KEYS_AND_CERT_MIN_SIZE:]
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if data_len < KEYS_AND_CERT_MIN_SIZE+cert_len {
|
||||||
|
cert.CertBytes = append(cert.Cert(), data[KEYS_AND_CERT_MIN_SIZE:]...)
|
||||||
|
err = cert_len_err
|
||||||
|
} else {
|
||||||
|
cert.CertBytes = append(cert.Cert(), data[KEYS_AND_CERT_MIN_SIZE:KEYS_AND_CERT_MIN_SIZE+cert_len]...)
|
||||||
|
remainder = data[KEYS_AND_CERT_MIN_SIZE+cert_len:]
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,8 @@ const (
|
|||||||
|
|
||||||
type LeaseSet struct {
|
type LeaseSet struct {
|
||||||
Destination
|
Destination
|
||||||
|
crypto.SigningPublicKey
|
||||||
|
crypto.PublicKey
|
||||||
LeaseList []Lease
|
LeaseList []Lease
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +115,7 @@ func (lease_set LeaseSet) GetDestination() (destination Destination, err error)
|
|||||||
//
|
//
|
||||||
// Return the PublicKey in this LeaseSet and any errors ancountered parsing the LeaseSet.
|
// Return the PublicKey in this LeaseSet and any errors ancountered parsing the LeaseSet.
|
||||||
//
|
//
|
||||||
func (lease_set LeaseSet) PublicKey() (public_key crypto.ElgPublicKey, err error) {
|
/*func (lease_set LeaseSet) PublicKey() (public_key crypto.ElgPublicKey, err error) {
|
||||||
_, remainder, err := ReadKeysAndCert(lease_set)
|
_, remainder, err := ReadKeysAndCert(lease_set)
|
||||||
remainder_len := len(remainder)
|
remainder_len := len(remainder)
|
||||||
if remainder_len < LEASE_SET_PUBKEY_SIZE {
|
if remainder_len < LEASE_SET_PUBKEY_SIZE {
|
||||||
@ -129,15 +131,15 @@ func (lease_set LeaseSet) PublicKey() (public_key crypto.ElgPublicKey, err error
|
|||||||
}
|
}
|
||||||
copy(public_key[:], remainder[:LEASE_SET_PUBKEY_SIZE])
|
copy(public_key[:], remainder[:LEASE_SET_PUBKEY_SIZE])
|
||||||
return
|
return
|
||||||
}
|
}*/
|
||||||
|
|
||||||
//
|
//
|
||||||
// Return the SigningPublicKey, as specified in the LeaseSet's Destination's Key Certificate if
|
// Return the SigningPublicKey, as specified in the LeaseSet's Destination's Key Certificate if
|
||||||
// present, or a legacy DSA key.
|
// present, or a legacy DSA key.
|
||||||
//
|
//
|
||||||
|
|
||||||
func (lease_set LeaseSet) SigningKey() (signing_public_key crypto.SigningPublicKey, err error) {
|
/*func (lease_set LeaseSet) SigningKey() (signing_public_key crypto.SigningPublicKey, err error) {
|
||||||
destination, err := lease_set.Destination()
|
destination, err := lease_set.GetDestination()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -187,12 +189,12 @@ func (lease_set LeaseSet) SigningKey() (signing_public_key crypto.SigningPublicK
|
|||||||
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}*/
|
||||||
|
|
||||||
//
|
//
|
||||||
// Return the number of Leases specified by the LeaseCount value in this LeaseSet.
|
// Return the number of Leases specified by the LeaseCount value in this LeaseSet.
|
||||||
//
|
//
|
||||||
func (lease_set LeaseSet) LeaseCount() (count int, err error) {
|
/*func (lease_set LeaseSet) LeaseCount() (count int, err error) {
|
||||||
_, remainder, err := ReadKeysAndCert(lease_set)
|
_, remainder, err := ReadKeysAndCert(lease_set)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -218,12 +220,12 @@ func (lease_set LeaseSet) LeaseCount() (count int, err error) {
|
|||||||
err = errors.New("invalid lease set: more than 16 leases")
|
err = errors.New("invalid lease set: more than 16 leases")
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}*/
|
||||||
|
|
||||||
//
|
//
|
||||||
// Read the Leases in this LeaseSet, returning a partial set if there is insufficient data.
|
// Read the Leases in this LeaseSet, returning a partial set if there is insufficient data.
|
||||||
//
|
//
|
||||||
func (lease_set LeaseSet) Leases() (leases []Lease, err error) {
|
/*func (lease_set LeaseSet) Leases() (leases []Lease, err error) {
|
||||||
destination, err := lease_set.Destination()
|
destination, err := lease_set.Destination()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -252,13 +254,13 @@ func (lease_set LeaseSet) Leases() (leases []Lease, err error) {
|
|||||||
leases = append(leases, lease)
|
leases = append(leases, lease)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}*/
|
||||||
|
|
||||||
//
|
//
|
||||||
// Return the Signature data for the LeaseSet, as specified in the Destination's
|
// Return the Signature data for the LeaseSet, as specified in the Destination's
|
||||||
// Key Certificate if present or the 40 bytes following the Leases.
|
// Key Certificate if present or the 40 bytes following the Leases.
|
||||||
//
|
//
|
||||||
func (lease_set LeaseSet) Signature() (signature Signature, err error) {
|
/*func (lease_set LeaseSet) Signature() (signature Signature, err error) {
|
||||||
destination, err := lease_set.Destination()
|
destination, err := lease_set.Destination()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -296,11 +298,12 @@ func (lease_set LeaseSet) Signature() (signature Signature, err error) {
|
|||||||
}
|
}
|
||||||
signature = []byte(lease_set[start:end])
|
signature = []byte(lease_set[start:end])
|
||||||
return
|
return
|
||||||
}
|
}*/
|
||||||
|
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
/*
|
||||||
func (lease_set LeaseSet) Verify() error {
|
func (lease_set LeaseSet) Verify() error {
|
||||||
//data_end := len(destination) +
|
//data_end := len(destination) +
|
||||||
// LEASE_SET_PUBKEY_SIZE +
|
// LEASE_SET_PUBKEY_SIZE +
|
||||||
@ -352,4 +355,6 @@ func (lease_set LeaseSet) OldestExpiration() (earliest Date, err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
//func ReadKeysAndCert(data []byte) (keys_and_cert KeysAndCert, remainder []byte, err error) {}
|
||||||
|
Reference in New Issue
Block a user