Skip to content

Commit

Permalink
parse private key elements as an array
Browse files Browse the repository at this point in the history
  • Loading branch information
freigeistig committed May 15, 2024
1 parent 611012d commit 1857063
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 35 deletions.
16 changes: 15 additions & 1 deletion internal/service/api/handlers/create_identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,21 @@ func CreateIdentity(w http.ResponseWriter, r *http.Request) {
return
}

if err := validatePubSignals(cfg, req.Data, encapsulatedData.PrivateKey.El1.OctetStr.Bytes); err != nil {
privateKey := make([]asn1.RawValue, 0)
if _, err = asn1.Unmarshal(encapsulatedData.PrivateKey.FullBytes, &privateKey); err != nil {
Log(r).WithError(err).Error("failed to unmarshal ASN.1")
ape.RenderErr(w, problems.InternalError())
return
}

privKeyEl := resources.PrivateKeyElement{}
if _, err = asn1.Unmarshal(privateKey[0].FullBytes, &privKeyEl); err != nil {
Log(r).WithError(err).Error("failed to unmarshal ASN.1")
ape.RenderErr(w, problems.InternalError())
return
}

if err := validatePubSignals(cfg, req.Data, privKeyEl.OctetStr.Bytes); err != nil {
Log(r).WithError(err).Error("failed to validate pub signals")
ape.RenderErr(w, problems.BadRequest(err)...)
return
Expand Down
40 changes: 6 additions & 34 deletions resources/document_sod.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,10 @@ type DigestAttribute struct {
type EncapsulatedData struct {
Version int
PrivateKeyAlgorithm asn1.RawValue
PrivateKey struct {
El1 struct {
Integer int
OctetStr asn1.RawValue
}
El2 struct {
Integer int
OctetStr asn1.RawValue
}
El3 struct {
Integer int
OctetStr asn1.RawValue
}
El4 struct {
Integer int
OctetStr asn1.RawValue
}
El5 struct {
Integer int
OctetStr asn1.RawValue
}
El6 struct {
Integer int
OctetStr asn1.RawValue
}
El7 struct {
Integer int
OctetStr asn1.RawValue
}
El8 struct {
Integer int
OctetStr asn1.RawValue
}
}
PrivateKey asn1.RawValue
}

type PrivateKeyElement struct {
Integer int
OctetStr asn1.RawValue
}

0 comments on commit 1857063

Please sign in to comment.