func main() {

	//pass in assertion.xml
	assertion := checkArgs()

	//parse xml file for encrypted key and assertion
	_, encrypted_key, encrypted_assertion, err := parseXML(assertion)

	//get private key
	priv_key := getPrivKey(key_location)

	//base64 encrypted key to hex
	encrypted_key_base64, err := decode.Base64ToString(string(encrypted_key))
	check("Error decoding encrypted key %s\n", err)

	//decrypt key
	decrypted_key, err := crypto.DecryptOAEPsha1(priv_key, encrypted_key_base64)
	check("Encrypted key failed to decrypt: %s\n", err)
	decrypted_hex_key := decode.ByteToHexString([]byte(decrypted_key))

	//decode base64 assertion
	base64_assertion, err := decode.Base64ToString(encrypted_assertion)
	check("Invalid Base64 => %s\n", err)
	enc_assertion_hex := decode.ByteToHexString(base64_assertion)

	//decode key
	enc_key, err := decode.HexStringToByte(decrypted_hex_key)
	check("Error decoding decrypted key %s\n", err)

	//hex decode assertion
	cipher_text, err := decode.HexStringToByte(enc_assertion_hex)
	check("Error decoding decrypted key %s\n", err)

	//decrypt assertion
	decrypted_saml_assertion, err := crypto.DecryptSAML(enc_key, cipher_text)
	check("Error decrypting SAML assertion %s\n", err)

	//write decrypted output to file
	saml_contents := []byte(decrypted_saml_assertion)

	//TODO: parse `xml:"Issuer"` for assigning unique file name

	//for now, we'll use a Unix timestamp
	timestamp := strconv.FormatInt(time.Now().Unix(), 10)
	err = ioutil.WriteFile(timestamp+"_decrypted_assertion.xml", saml_contents, 0644)
	check("Error writing decrypted assertion to file %s\n", err)
}
//decode & decrypt SAML assertions
decode & decrypt SAML assertions
// decode & decrypt SAML assertions
func main() {
	assertion := checkArgs()
	_, encrypted_key, encrypted_assertion, err := parseXML(assertion)
	priv_key := getPrivKey(key_location)
	encrypted_key_base64, err := decode.Base64ToString(string(encrypted_key))
	check("Error decoding encrypted key %s\n", err)
	decrypted_key, err := crypto.DecryptOAEPsha1(priv_key, encrypted_key_base64)
	check("Encrypted key failed to decrypt: %s\n", err)
	decrypted_hex_key := decode.ByteToHexString([]byte(decrypted_key))
	base64_assertion, err := decode.Base64ToString(encrypted_assertion)
	check("Invalid Base64 => %s\n", err)
	enc_assertion_hex := decode.ByteToHexString(base64_assertion)
	enc_key, err := decode.HexStringToByte(decrypted_hex_key)
	check("Error decoding decrypted key %s\n", err)
	cipher_text, err := decode.HexStringToByte(enc_assertion_hex)
	check("Error decoding decrypted key %s\n", err)
	decrypted_saml_assertion, err := crypto.DecryptSAML(enc_key, cipher_text)
	check("Error decrypting SAML assertion %s\n", err)
	saml_contents := []byte(decrypted_saml_assertion)
	timestamp := strconv.FormatInt(time.Now().Unix(), 10)
	err = ioutil.WriteFile(timestamp+"_decrypted_assertion.xml", saml_contents, 0644)
	check("Error writing decrypted assertion to file %s\n", err)
}
func main ( ) { assertion := checkArgs ( ) _ , encrypted_key , encrypted_assertion , err := parseXML ( assertion ) priv_key := getPrivKey ( key_location ) encrypted_key_base64 , err := decode . Base64ToString ( string ( encrypted_key ) ) check ( " \n " , err ) decrypted_key , err := crypto . DecryptOAEPsha1 ( priv_key , encrypted_key_base64 ) check ( " \n " , err ) decrypted_hex_key := decode . ByteToHexString ( [ ] byte ( decrypted_key ) ) base64_assertion , err := decode . Base64ToString ( encrypted_assertion ) check ( " \n " , err ) enc_assertion_hex := decode . ByteToHexString ( base64_assertion ) enc_key , err := decode . HexStringToByte ( decrypted_hex_key ) check ( " \n " , err ) cipher_text , err := decode . HexStringToByte ( enc_assertion_hex ) check ( " \n " , err ) decrypted_saml_assertion , err := crypto . DecryptSAML ( enc_key , cipher_text ) check ( " \n " , err ) saml_contents := [ ] byte ( decrypted_saml_assertion ) timestamp := strconv . FormatInt ( time . Now ( ) . Unix ( ) , 10 ) err = ioutil . WriteFile ( timestamp + " " , saml_contents , 0644 ) check ( " \n " , err ) }
decode & decrypt SAML assertions
decode & decrypt SAML assertions
//pass in assertion.xml //parse xml file for encrypted key and assertion //get private key //base64 encrypted key to hex //decrypt key //decode base64 assertion //decode key //hex decode assertion //decrypt assertion //write decrypted output to file //TODO: parse `xml:"Issuer"` for assigning unique file name //for now, we'll use a Unix timestamp