This commit is contained in:
Haris Khan
2024-11-26 19:47:17 -05:00
parent 37e11ffee1
commit 7a6927cf53
10 changed files with 19 additions and 10 deletions

View File

@ -6,6 +6,7 @@ import (
"encoding/binary"
"errors"
"fmt"
"github.com/sirupsen/logrus"
// log "github.com/sirupsen/logrus"

View File

@ -2,6 +2,7 @@ package data
import (
"errors"
"github.com/sirupsen/logrus"
)
@ -91,13 +92,12 @@ func (str I2PString) Data() (data string, err error) {
case ErrDataTooLong:
log.WithError(err).Warn("I2PString contains data beyond specified length")
data = string(str[1:])
//data = string(str[1 : length+1]) // Should we recover and trim?
// data = string(str[1 : length+1]) // Should we recover and trim?
return
default:
log.WithError(err).Error("Unknown error encountered in I2PString.Data()")
return "", err
}
}
if length == 0 {
log.Debug("I2PString is empty")

View File

@ -379,6 +379,7 @@ func KeyCertificateFromCertificate(certificate Certificate) (*KeyCertificate, er
log.Debug("Successfully created keyCertificate from Certificate")
return k, nil
}
func NewKeyCertificateFromCertificate(cert Certificate) (*KeyCertificate, error) {
payload := cert.Data()
if len(payload) < 4 {

View File

@ -418,6 +418,7 @@ func readCertificateFromEnd(data []byte) (cert Certificate, certStartIndex int,
err = errors.New("could not find certificate in data")
return
}
func constructPublicKey(data []byte, cryptoType uint16) (crypto.PublicKey, error) {
switch cryptoType {
case CRYPTO_KEY_TYPE_ELGAMAL:

View File

@ -3,12 +3,13 @@ package keys_and_cert
import (
"bytes"
"crypto/rand"
"testing"
"github.com/go-i2p/go-i2p/lib/common/certificate"
"github.com/go-i2p/go-i2p/lib/common/data"
"github.com/go-i2p/go-i2p/lib/common/key_certificate"
"github.com/go-i2p/go-i2p/lib/crypto"
"golang.org/x/crypto/openpgp/elgamal"
"testing"
"github.com/stretchr/testify/assert"
)

View File

@ -4,10 +4,11 @@ package lease
import (
"encoding/binary"
"errors"
"time"
. "github.com/go-i2p/go-i2p/lib/common/data"
"github.com/go-i2p/go-i2p/lib/util/logger"
"github.com/sirupsen/logrus"
"time"
)
// Sizes in bytes of various components of a Lease

View File

@ -4,6 +4,7 @@ package lease_set
import (
"errors"
"fmt"
"github.com/go-i2p/go-i2p/lib/common/signature"
"github.com/go-i2p/go-i2p/lib/util/logger"

View File

@ -4,13 +4,14 @@ import (
"bytes"
"crypto/rand"
"fmt"
"testing"
"time"
"github.com/go-i2p/go-i2p/lib/common/data"
"github.com/go-i2p/go-i2p/lib/common/destination"
"github.com/go-i2p/go-i2p/lib/common/keys_and_cert"
"github.com/go-i2p/go-i2p/lib/crypto"
"golang.org/x/crypto/openpgp/elgamal"
"testing"
"time"
"github.com/go-i2p/go-i2p/lib/common/certificate"
"github.com/go-i2p/go-i2p/lib/common/lease"

View File

@ -4,11 +4,12 @@ import (
"bytes"
"crypto/rand"
"encoding/binary"
"github.com/go-i2p/go-i2p/lib/common/key_certificate"
"github.com/go-i2p/go-i2p/lib/common/keys_and_cert"
"testing"
"time"
"github.com/go-i2p/go-i2p/lib/common/key_certificate"
"github.com/go-i2p/go-i2p/lib/common/keys_and_cert"
"github.com/go-i2p/go-i2p/lib/common/signature"
"github.com/go-i2p/go-i2p/lib/common/certificate"

View File

@ -4,6 +4,9 @@ import (
"bytes"
"crypto/rand"
"fmt"
"testing"
"time"
"github.com/go-i2p/go-i2p/lib/common/certificate"
"github.com/go-i2p/go-i2p/lib/common/data"
"github.com/go-i2p/go-i2p/lib/common/key_certificate"
@ -12,8 +15,6 @@ import (
"github.com/go-i2p/go-i2p/lib/crypto"
"github.com/stretchr/testify/assert"
"golang.org/x/crypto/openpgp/elgamal"
"testing"
"time"
"github.com/go-i2p/go-i2p/lib/common/router_address"
)