Golang crypto/x509.SignatureAlgorithm type example
package crypto/x509
Golang crypto/x509.SignatureAlgorithm type usage examples
if err := x509.CheckSignature(cert.SignatureAlgorithm, cert.RawTBSCertificate, cert.Signature); err != nil {
fmt.Println("Corrupted signature on embedded certificate")
}
or
switch {
case x509Cert.SignatureAlgorithm == x509.MD2WithRSA:
return "MD2WithRSA Algorithm"
case x509Cert.SignatureAlgorithm == x509.MD5WithRSA:
return "MD5WithRSA Algorithm"
case x509Cert.SignatureAlgorithm == x509.SHA1WithRSA:
return "SHA1WithRSA Algorithm"
case x509Cert.SignatureAlgorithm == x509.SHA256WithRSA:
return "SHA256WithRSA Algorithm"
case x509Cert.SignatureAlgorithm == x509.SHA384WithRSA:
return "SHA384WithRSA Algorithm"
case x509Cert.SignatureAlgorithm == x509.SHA512WithRSA:
return "SHA512WithRSA Algorithm"
case x509Cert.SignatureAlgorithm == x509.DSAWithSHA1:
return "DSAWithSHA1 Algorithm"
case x509Cert.SignatureAlgorithm == x509.DSAWithSHA256:
return "DSAWithSHA256 Algorithm"
case x509Cert.SignatureAlgorithm == x509.ECDSAWithSHA1:
return "ECDSAWithSHA1 Algorithm"
case x509Cert.SignatureAlgorithm == x509.ECDSAWithSHA256:
return "ECDSAWithSHA256 Algorithm"
case x509Cert.SignatureAlgorithm == x509.ECDSAWithSHA384:
return "ECDSAWithSHA384 Algorithm"
case x509Cert.SignatureAlgorithm == x509.ECDSAWithSHA512:
return "ECDSAWithSHA512 Algorithm"
default:
return "UnknownSignatureAlgorithm"
}
Reference :
Advertisement
Something interesting
Tutorials
+7.3k Golang : How to iterate a slice without using for loop?
+21.3k Golang : Create and resolve(read) symbolic links
+5.2k Golang : Experimental Jawi programming language
+13.7k Golang : Check if an integer is negative or positive
+8.1k Golang : Randomize letters from a string example
+87.8k Golang : How to convert character to ASCII and back
+40.5k Golang : Convert to io.ReadSeeker type
+7.4k Golang : Hue, Saturation and Value(HSV) with OpenCV example
+47.8k Golang : Convert int to byte array([]byte)
+12.3k Golang : Display list of countries and ISO codes
+9k Golang : How to use Gorilla webtoolkit context package properly
+18.4k Golang : Logging with logrus