-
Notifications
You must be signed in to change notification settings - Fork 1
/
testlibsaml.c
164 lines (145 loc) · 10.7 KB
/
testlibsaml.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#include <samlc.h>
#include <stdio.h>
#include <stdlib.h>
#define SAML_RESPONSE "<?xml version=\"1.0\" encoding=\"UTF-8\"?><samlp:Response xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\" Destination=\"https://bachelor.lan:9875/samlResponse\" ID=\"1320364198133.127.0.0.1.7992992958593679671\" InResponseTo=\"0x8c4e6675f042f2229c901c34c71b8050\" IssueInstant=\"2011-11-03T23:49:58.133Z\" Version=\"2.0\"><saml:Issuer xmlns:saml=\"urn:oasis:names:tc:SAML:2.0:assertion\">Governikus Autent</saml:Issuer><ds:Signature xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\">\
<ds:SignedInfo>\
<ds:CanonicalizationMethod Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\"/>\
<ds:SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\"/>\
<ds:Reference URI=\"#1320364198133.127.0.0.1.7992992958593679671\">\
<ds:Transforms>\
<ds:Transform Algorithm=\"http://www.w3.org/2000/09/xmldsig#enveloped-signature\"/>\
<ds:Transform Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\"><ec:InclusiveNamespaces xmlns:ec=\"http://www.w3.org/2001/10/xml-exc-c14n#\" PrefixList=\"ds saml samlp xenc\"/></ds:Transform>\
</ds:Transforms>\
<ds:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/>\
<ds:DigestValue>MbQg1TvXBSDTcvmwllmmJbOs0Zc=</ds:DigestValue>\
</ds:Reference>\
</ds:SignedInfo>\
<ds:SignatureValue>\
XPAx++0oP1bkow4DoNonhpKsn3PVk2Ab6l4t4JRQ/+hjIcAlb2sTLxirvF5Oou2E2K2ZSM9lKk4g\
xzwVaoeNGSIBTOYxBu7QXyMNfO2FpA7CVD4DmrGG+kyz24siohk63jeGB2pmhTzl5cpGO1xcRrF8\
GHBmMHqQMxMXbXQg4YRgFvXBWa1iT/BGa0dlpxTkMH69Xy/veh5xG+VxqJKk+bNbT/A85MVNerOK\
EaFoTdXsHuAh7NNDBTxi5KB9Bsvc2COnYN7M6gD9i++S6+vo273U9anLhwpdYtKfjJvt9TfXF8h+\
RK4VDyinZWwR/RzLW6XhyiqpD4WAKGDm2TYyKw==\
</ds:SignatureValue>\
<ds:KeyInfo><ds:X509Data><ds:X509Certificate>MIIDZDCCAkygAwIBAgIDAfXPMA0GCSqGSIb3DQEBCwUAMDUxGDAWBgNVBAMMD2JvcyB0ZXN0IGlz\
c3VlcjELMAkGA1UEBhMCREUxDDAKBgNVBAoMA2JvczAeFw0wOTEwMDIxMzQwNDhaFw0xMjEwMDEx\
MzQwNDhaMEgxKzApBgNVBAMMIkdvdmVybmlrdXMgSWRlbnRpdHkgTWFuYWdlciAoVGVzdCkxCzAJ\
BgNVBAYTAkRFMQwwCgYDVQQKDANib3MwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCD\
nVPhVnZylgTxVo0JezkWeOwFz+uBq4HLEc3pplah3k5fs8AGtR43X35lfoVTzt1yf56se4cx/sqP\
EU3/nIxQVlL9Dm27cD2lEk+X8FlQzmV6EDHaFICSUU88IZq9X4OnWcyxw48LtgnsDvc9UpQoPNxp\
NuLxvU5CtxvnP9U8oyYyONuq39i0DYOaV/PpPj8C7T5pZ8PAb9l6DM1ufE3bqcsiZTzcoq3mYYj0\
VGyJ+YunkD6FAH+pNh1ag5dxt4wp+L4WJsTzzrYESkPytmayfwtN721YFkPXOM/DB4vpE5Ak5TyJ\
mylI0nvdCdk4ul4m3OejFc9KkpABqRrnV+URAgMBAAGjajBoMB0GA1UdDgQWBBT0MepFRAPp0CF5\
HdQIIpT9Wtpp2TAfBgNVHSMEGDAWgBQVrcPt1EzaZuATCiEecQ+SUG6SzzAOBgNVHQ8BAf8EBAMC\
BJAwFgYDVR0lAQH/BAwwCgYIKwYBBQUHAwgwDQYJKoZIhvcNAQELBQADggEBAHJIwr0lTF9HhFEU\
1X9wGZZv9wM2bnUcYY5AQar8REAs0TD1RjQfccpxSASBGLPjAcxly3uPrtxrjQ1vanpH4rOBm+2e\
3cZWUH/AYBEXfd6uRmWg62mlVi0BCINwjXK7rxc2Drpmg4JooKewqC/zQlKqw7Ada0ysm/IsTkgA\
Sr+4rjVtfV83iW/fcWll7pCqp5suAJpaf9dvjr1oo3O7OFofgE0VYma6yNTvvreN/mzYYoy1HUjI\
aJiM2dqaGg+Dfp8m9BmSL6knHHU8gsXQPtH77BMtkDc+B+avon0DVzjr7cMDz6whV8O/WmeODctl\
ZqbyvNA0mhrK59U8Ms5smzQ=</ds:X509Certificate></ds:X509Data></ds:KeyInfo></ds:Signature><samlp:Status><samlp:StatusCode Value=\"urn:oasis:names:tc:SAML:2.0:status:Success\"/></samlp:Status><saml:EncryptedAssertion xmlns:saml=\"urn:oasis:names:tc:SAML:2.0:assertion\"><xenc:EncryptedData xmlns:xenc=\"http://www.w3.org/2001/04/xmlenc#\" Id=\"_2bb5e874fe2c27ef02918ad423706654\" Type=\"http://www.w3.org/2001/04/xmlenc#Element\"><xenc:EncryptionMethod Algorithm=\"http://www.w3.org/2001/04/xmlenc#aes128-cbc\" xmlns:xenc=\"http://www.w3.org/2001/04/xmlenc#\"/><ds:KeyInfo xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\"><xenc:EncryptedKey Id=\"_899f65fd331f3e3fc5f515d6900576dd\" xmlns:xenc=\"http://www.w3.org/2001/04/xmlenc#\"><xenc:EncryptionMethod Algorithm=\"http://www.w3.org/2001/04/xmlenc#rsa-1_5\" xmlns:xenc=\"http://www.w3.org/2001/04/xmlenc#\"/><ds:KeyInfo><ds:X509Data><ds:X509Certificate>MIIDYTCCAkmgAwIBAgIDAfXPMA0GCSqGSIb3DQEBCwUAMDUxGDAWBgNVBAMMD2JvcyB0ZXN0IGlz\
c3VlcjELMAkGA1UEBhMCREUxDDAKBgNVBAoMA2JvczAeFw0wOTEwMDIxMzQxMThaFw0xMjA5MzAy\
MjAwMDBaMEUxKDAmBgNVBAMMH0V4YW1wbGUgU2VydmljZSBQcm92aWRlciAoVGVzdCkxCzAJBgNV\
BAYTAkRFMQwwCgYDVQQKDANib3MwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC5237+\
fXXjjFHda8CZt8ZANpxKExz1RYrtE+1EXh3AgrfkwwCyYNaB8/q/LgzCZYfocHJJdWyJLnQTU+ln\
SxC+12sV1wLv/Pi++smpmBAr8cOdNHfFRNFQJA9Rng8agYXBGDehtrn3uTq/DwNEkPy9UTCSjHie\
HefXAK9Be8kfBI76q492Sj2C58vNCjAt6UkEn79mTl+bDSkZbHEdsnHz7YcRfovnTQMvZXviqnpH\
XkCcp5ZBCv+PybpKqXM9tbLcRVmGgpSz6D9aTkr/ZRYS5cHQ+jV7Ir1g9VXpk3raMMh75QL0oPuf\
Ssoth91zyueGxo6zTKsodG5s2xcs14CfAgMBAAGjajBoMB0GA1UdDgQWBBR7Qwoq4XI+RdmTcppv\
y2C2r5T/LTAfBgNVHSMEGDAWgBT0a1xy4ny8H72MRAeJ/yrgm1QAqTAOBgNVHQ8BAf8EBAMCBJAw\
FgYDVR0lAQH/BAwwCgYIKwYBBQUHAwgwDQYJKoZIhvcNAQELBQADggEBAAJABaeX7kucVjPUAcdm\
Doz+dOO8/Tr6rNzKBNyOCQGHAbrVYbLPDj2T/j7MqqDbgYe8a8/mZ25VNI/VZ36jc/BZPkCVOuCR\
nYh0poGHlhFkYpK9RVk1O8lEBk/CemOuRwpLrFg4Z32V3XSFtTB26HEo1nqhBVAeY1xFbxrua3nx\
UmFVm4Hh39YKxzJf6fmsN8B0HYjM7AGtGnPLDyQc4U2VuBpxV9E5LhoMgi3gKvoFVaeAt3UwupKZ\
SYQkQ3nrd6JYeLTVJ2dnGRqVPxgrPLelOZ73sY/Iv4hJI9f/01KFcVyl6Km7UmVS5952Pe03PWpU\
ZJHOPilF3FvLch1/nH8=</ds:X509Certificate></ds:X509Data></ds:KeyInfo><xenc:CipherData xmlns:xenc=\"http://www.w3.org/2001/04/xmlenc#\"><xenc:CipherValue xmlns:xenc=\"http://www.w3.org/2001/04/xmlenc#\">G4lP6M1QxUHWYmXkiYG+nbzP/fUeG7Bk72u/PsP7yFGev3RRvYzO+i7m/aK9VIlAFo00qHHjlAjN\
f/jmk5IKW3an1diKNBCsioPFf10yM1yZtOuLH7+E+9NFOnCDWB4hA20QY1LxxznV+UmBhUEsflDf\
M0M4QdslF8pvBmScAEveEdZBIUGEM+UWjlk+LN4VEJyEX6URU7v5tQRIIPDHH4f3BiHxfRNTK5O1\
MTcTycXp7HSA1JQx3bdWA6g/UwO3xwJEdoGAwT2FJjn2ZuKGuLs5D7BYiCLVSBWgbhb8lSdAJizV\
b/GwJVZaoJmQKbRAEatxTp7U7Cyy4wSaES0t2A==</xenc:CipherValue></xenc:CipherData></xenc:EncryptedKey></ds:KeyInfo><xenc:CipherData xmlns:xenc=\"http://www.w3.org/2001/04/xmlenc#\"><xenc:CipherValue xmlns:xenc=\"http://www.w3.org/2001/04/xmlenc#\">aaM+e8PHWj4TnN6mtVZW+OqL02n6wEZHc01gxHcad+xNymFwGqoycgzhLScaJ9SaEC/0jXUienVX\
P+XflQaItDeP5qg0sypmxtQW92fqf8AOuEx8ld16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GmfCgRfnLsAv\
7tO3CmGiQCH9QNs6ShI02bRFUBsoUCwCQy3ykGVL2fP4gmxPyh2OzZWwRT9YfgbhTq0TggMfQcvq\
6lerlUu2zH7C0qtHrrNSKhWaMPwSc8tsHLXCKd24UkNUI43UUO2jN+qoqWFfcCjFAxRx7onCeqtJ\
oyiGJ7+tgqyMe/APQKvg9BlFS/JKePoY9HX30dEAfnEJUDWh9EAQzGjnhZihSJIuLfhA7kpVBwZa\
dLKLKdAvq/HCwNXjC+/muDZLrNvkPbNrXLIizvbT59QgaKLFr52/61bm1diwW1O9BeoFbpgzQibl\
0I1EwNqO6mIjX0r19F/bk3y6dW5cNerP7B+4fTYToMtvscz6hV42+lMHYbdWQ/FfJZSH1ew/+mBu</xenc:CipherValue></xenc:CipherData></xenc:EncryptedData></saml:EncryptedAssertion></samlp:Response>\n"
#define DEC_KEY_PATH "/home/hauke/uni/bachelor-git/mongoose/serviceProvider_decrypt.pem"
#define DEC_KEY_ALIAS "demo_epa_dummy_applet"
int parse()
{
struct saml_response *response;
char *elem;
saml_init();
if (saml_parse(SAML_RESPONSE, DEC_KEY_PATH, DEC_KEY_ALIAS, NULL,
&response)) {
printf("can not parse saml response \n");
return -1;
}
printf("Assertion: %s\n", response->assertion_char);
elem = saml_get_char_xpath(response->assertion, "//saml:Assertion/saml:AttributeStatement/saml:Attribute", "FamilyNames");
printf("elem: %s\n", elem);
free(elem);
elem = saml_get_char_xpath(response->assertion, "//saml:Assertion/saml:AttributeStatement/saml:Attribute", "GivenNames");
printf("elem: %s\n", elem);
free(elem);
elem = saml_get_char_xpath(response->assertion, "//saml:Assertion/saml:AttributeStatement/saml:Attribute", "PlaceOfResidence");
printf("elem: %s\n", elem);
free(elem);
saml_free_response(response);
saml_term();
return 0;
}
int create()
{
char *result;
saml_init();
saml_create("demo_epa_dummy_applet", "123", "https://192.168.56.1:8443/gov_autent/async",NULL, NULL, NULL, "/home/hauke/uni/bachelor-git/mongoose/serviceProvider_new.pem", "/home/hauke/uni/bachelor-git/mongoose/serviceProvider_new_cert.pem", &result);
printf("elem: %s\n", result);
free(result);
saml_term();
return 0;
}
int main()
{
return create();
}