File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -323,25 +323,19 @@ func createTBSCertificate(template *Certificate, sigAlg SignatureAlgorithm) ([]b
323323 var publicKeyBytes []byte
324324 if template .PublicKey != nil {
325325 if gostPub , ok := template .PublicKey .(* gost3410.PublicKey ); ok {
326- // Encode GOST public key as X and Y coordinates
326+ // Encode GOST public key according to GOST R 34.10-2012 standard
327+ // The public key should be encoded as a BIT STRING containing the raw public key
327328 xBytes := gostPub .X .Bytes ()
328329 yBytes := gostPub .Y .Bytes ()
329330
330- // Create GOST public key structure
331- gostPubKey := struct {
332- X []byte
333- Y []byte
334- }{
335- X : xBytes ,
336- Y : yBytes ,
337- }
331+ // Combine X and Y coordinates into a single byte array
332+ // GOST public key format: 04 || X || Y (uncompressed format)
333+ pubKeyRaw := make ([]byte , 1 + len (xBytes )+ len (yBytes ))
334+ pubKeyRaw [0 ] = 0x04 // Uncompressed point indicator
335+ copy (pubKeyRaw [1 :], xBytes )
336+ copy (pubKeyRaw [1 + len (xBytes ):], yBytes )
338337
339- // Marshal to ASN.1 DER
340- pubKeyDER , err := asn1 .Marshal (gostPubKey )
341- if err != nil {
342- return nil , fmt .Errorf ("failed to marshal GOST public key: %w" , err )
343- }
344- publicKeyBytes = pubKeyDER
338+ publicKeyBytes = pubKeyRaw
345339 }
346340 }
347341
You can’t perform that action at this time.
0 commit comments