mirror of
https://github.com/RedTeamPentesting/adauth
synced 2026-06-08 12:20:46 +00:00
pkinit: Replace OID literals by their names
This commit is contained in:
@@ -11,6 +11,17 @@ import (
|
||||
"github.com/jcmturner/gokrb5/v8/types"
|
||||
)
|
||||
|
||||
var (
|
||||
signedDataOID = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 7, 2}
|
||||
idPKINITAuthDataOID = asn1.ObjectIdentifier{1, 3, 6, 1, 5, 2, 3, 1}
|
||||
idPKINITDHKeyDataOID = asn1.ObjectIdentifier{1, 3, 6, 1, 5, 2, 3, 2}
|
||||
sha1HashOID = asn1.ObjectIdentifier{1, 3, 14, 3, 2, 26}
|
||||
sha1WithRSAEncryptionOID = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 1, 5}
|
||||
contentTypeOID = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 9, 3}
|
||||
ephemeralStaticDiffieHellmanKeyAgreementAlgorithmOID = asn1.ObjectIdentifier{1, 2, 840, 10046, 2, 1}
|
||||
messageDigestOID = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 9, 4}
|
||||
)
|
||||
|
||||
type SignerInfo struct {
|
||||
Version int `asn1:"default:1"`
|
||||
IssuerAndSerialNumber IssuerAndSerial
|
||||
|
||||
+2
-2
@@ -63,7 +63,7 @@ func ExtractNegotiatedKey(
|
||||
return ekey, fmt.Errorf("unmarshal signed data: %w", err)
|
||||
}
|
||||
|
||||
if !contentInfo.ContentType.Equal(asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 7, 2}) {
|
||||
if !contentInfo.ContentType.Equal(signedDataOID) {
|
||||
return ekey, fmt.Errorf("unexpected outer content type: %s", contentInfo.ContentType)
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ func ExtractNegotiatedKey(
|
||||
return ekey, fmt.Errorf("unmarshal signed data: %w", err)
|
||||
}
|
||||
|
||||
if !signedData.ContentInfo.ContentType.Equal(asn1.ObjectIdentifier{1, 3, 6, 1, 5, 2, 3, 2}) {
|
||||
if !signedData.ContentInfo.ContentType.Equal(idPKINITDHKeyDataOID) {
|
||||
return ekey, fmt.Errorf("unexpected inner content type: %s", signedData.ContentInfo.ContentType)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ func ConfigureASReq(
|
||||
},
|
||||
ClientPublicValue: SubjectPublicKeyInfo{
|
||||
Algorithm: AlgorithmIdentifier{
|
||||
Algorithm: asn1.ObjectIdentifier{1, 2, 840, 10046, 2, 1},
|
||||
Algorithm: ephemeralStaticDiffieHellmanKeyAgreementAlgorithmOID,
|
||||
Parameters: DomainParameters{
|
||||
P: DiffieHellmanPrime,
|
||||
G: 2,
|
||||
|
||||
+7
-7
@@ -29,29 +29,29 @@ func PKCS7Sign(data []byte, key *rsa.PrivateKey, cert *x509.Certificate) ([]byte
|
||||
return nil, fmt.Errorf("marshal digest: %w", err)
|
||||
}
|
||||
|
||||
serializedPKInitOID, err := asn1.Marshal(asn1.ObjectIdentifier{1, 3, 6, 1, 5, 2, 3, 1})
|
||||
serializedPKInitOID, err := asn1.Marshal(idPKINITAuthDataOID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("marshal PKInit OID: %w", err)
|
||||
}
|
||||
|
||||
sha1AlgorithmIdentifier := pkix.AlgorithmIdentifier{
|
||||
Algorithm: asn1.ObjectIdentifier{1, 3, 14, 3, 2, 26},
|
||||
Algorithm: sha1HashOID,
|
||||
}
|
||||
|
||||
rsaWithSHA1AlgorithmIdentifier := pkix.AlgorithmIdentifier{
|
||||
Algorithm: asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 1, 5},
|
||||
Algorithm: sha1WithRSAEncryptionOID,
|
||||
}
|
||||
|
||||
authenticatedAttributes := []Attribute{
|
||||
{
|
||||
// ContentType
|
||||
Type: asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 9, 3},
|
||||
Type: contentTypeOID,
|
||||
// id-pkinit-authData
|
||||
Value: asn1.RawValue{Tag: 17, IsCompound: true, Bytes: serializedPKInitOID},
|
||||
},
|
||||
{
|
||||
// MessageDigest
|
||||
Type: asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 9, 4},
|
||||
Type: messageDigestOID,
|
||||
Value: asn1.RawValue{Tag: 17, IsCompound: true, Bytes: serializedDigest},
|
||||
},
|
||||
}
|
||||
@@ -66,7 +66,7 @@ func PKCS7Sign(data []byte, key *rsa.PrivateKey, cert *x509.Certificate) ([]byte
|
||||
DigestAlgorithmIdentifiers: []pkix.AlgorithmIdentifier{sha1AlgorithmIdentifier},
|
||||
ContentInfo: ContentInfo{
|
||||
// id-pkinit-authData
|
||||
ContentType: asn1.ObjectIdentifier{1, 3, 6, 1, 5, 2, 3, 1},
|
||||
ContentType: idPKINITAuthDataOID,
|
||||
Content: asn1.RawValue{Class: 2, Tag: 0, Bytes: serializedData, IsCompound: true},
|
||||
},
|
||||
Certificates: rawCert,
|
||||
@@ -90,7 +90,7 @@ func PKCS7Sign(data []byte, key *rsa.PrivateKey, cert *x509.Certificate) ([]byte
|
||||
|
||||
contentInfo := ContentInfo{
|
||||
// signed data
|
||||
ContentType: asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 7, 2},
|
||||
ContentType: signedDataOID,
|
||||
Content: asn1.RawValue{Class: 2, Tag: 0, Bytes: signedDataBytes, IsCompound: true},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user