2 * @file nexus.h MSN Nexus functions
6 * Purple is the legal property of its developers, whose names are too numerous
7 * to list here. Please refer to the COPYRIGHT file distributed with this
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
27 /* Index into ticket_tokens in nexus.c Keep updated! */
30 MSN_AUTH_MESSENGER = 0,
31 MSN_AUTH_MESSENGER_WEB = 1,
32 MSN_AUTH_CONTACTS = 2,
33 MSN_AUTH_LIVE_SECURE = 3,
35 MSN_AUTH_LIVE_CONTACTS = 5,
39 #define MSN_SSO_SERVER "login.live.com"
40 #define SSO_POST_URL "/RST.srf"
42 #define MSN_SSO_RST_TEMPLATE \
43 "<wst:RequestSecurityToken xmlns=\"http://schemas.xmlsoap.org/ws/2004/04/trust\" Id=\"RST%d\">"\
44 "<wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>"\
45 "<wsp:AppliesTo xmlns=\"http://schemas.xmlsoap.org/ws/2002/12/policy\">"\
46 "<wsa:EndpointReference xmlns=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\">"\
47 "<wsa:Address>%s</wsa:Address>"\
48 "</wsa:EndpointReference>"\
50 "<wsse:PolicyReference xmlns=\"http://schemas.xmlsoap.org/ws/2003/06/secext\" URI=\"%s\"></wsse:PolicyReference>"\
51 "</wst:RequestSecurityToken>"
53 #define MSN_SSO_TEMPLATE "<?xml version='1.0' encoding='utf-8'?>"\
54 "<Envelope xmlns=\"http://schemas.xmlsoap.org/soap/envelope/\""\
55 " xmlns:wsse=\"http://schemas.xmlsoap.org/ws/2003/06/secext\""\
56 " xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\""\
57 " xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2002/12/policy\""\
58 " xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\""\
59 " xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\""\
60 " xmlns:wssc=\"http://schemas.xmlsoap.org/ws/2004/04/sc\""\
61 " xmlns:wst=\"http://schemas.xmlsoap.org/ws/2004/04/trust\">"\
64 " xmlns:ps=\"http://schemas.microsoft.com/Passport/SoapServices/PPCRL\""\
65 " Id=\"PPAuthInfo\">"\
66 "<ps:HostingApp>{7108E71A-9926-4FCB-BCC9-9A9D3F32E423}</ps:HostingApp>"\
67 "<ps:BinaryVersion>4</ps:BinaryVersion>"\
68 "<ps:UIVersion>1</ps:UIVersion>"\
69 "<ps:Cookies></ps:Cookies>"\
70 "<ps:RequestParams>AQAAAAIAAABsYwQAAAAxMDMz</ps:RequestParams>"\
73 "<wsse:UsernameToken Id=\"user\">"\
74 "<wsse:Username>%s</wsse:Username>"\
75 "<wsse:Password>%s</wsse:Password>"\
76 "</wsse:UsernameToken>"\
80 "<ps:RequestMultipleSecurityTokens"\
81 " xmlns:ps=\"http://schemas.microsoft.com/Passport/SoapServices/PPCRL\""\
83 "<wst:RequestSecurityToken Id=\"RST0\">"\
84 "<wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>"\
86 "<wsa:EndpointReference>"\
87 "<wsa:Address>http://Passport.NET/tb</wsa:Address>"\
88 "</wsa:EndpointReference>"\
90 "</wst:RequestSecurityToken>"\
91 "%s" /* Other RSTn tokens */\
92 "</ps:RequestMultipleSecurityTokens>"\
96 #define MSN_SSO_AUTHINFO_TEMPLATE \
97 "<ps:AuthInfo xmlns:ps=\"http://schemas.microsoft.com/Passport/SoapServices/PPCRL\" Id=\"PPAuthInfo\">"\
98 "<ps:HostingApp>{7108E71A-9926-4FCB-BCC9-9A9D3F32E423}</ps:HostingApp>"\
99 "<ps:BinaryVersion>4</ps:BinaryVersion>"\
100 "<ps:UIVersion>1</ps:UIVersion>"\
101 "<ps:Cookies></ps:Cookies>"\
102 "<ps:RequestParams>AQAAAAIAAABsYwQAAAA0MTA1</ps:RequestParams>"\
104 /* Not sure what's editable here, so I'll just hard-code the SHA1 hash */
105 #define MSN_SSO_AUTHINFO_SHA1_BASE64 "d2IeTF4DAkPEa/tVETHznsivEpc="
107 #define MSN_SSO_TIMESTAMP_TEMPLATE \
108 "<wsu:Timestamp xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" Id=\"Timestamp\">"\
109 "<wsu:Created>%s</wsu:Created>"\
110 "<wsu:Expires>%s</wsu:Expires>"\
113 #define MSN_SSO_SIGNEDINFO_TEMPLATE \
114 "<SignedInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\">"\
115 "<CanonicalizationMethod Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\"></CanonicalizationMethod>"\
116 "<SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#hmac-sha1\"></SignatureMethod>"\
117 "<Reference URI=\"#RST%d\">"\
119 "<Transform Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\"></Transform>"\
121 "<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"></DigestMethod>"\
122 "<DigestValue>%s</DigestValue>"\
124 "<Reference URI=\"#Timestamp\">"\
126 "<Transform Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\"></Transform>"\
128 "<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"></DigestMethod>"\
129 "<DigestValue>%s</DigestValue>"\
131 "<Reference URI=\"#PPAuthInfo\">"\
133 "<Transform Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\"></Transform>"\
135 "<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"></DigestMethod>"\
136 "<DigestValue>" MSN_SSO_AUTHINFO_SHA1_BASE64 "</DigestValue>"\
140 #define MSN_SSO_TOKEN_UPDATE_TEMPLATE "<?xml version=\"1.0\" encoding=\"utf-8\"?>"\
142 " xmlns=\"http://schemas.xmlsoap.org/soap/envelope/\""\
143 " xmlns:wsse=\"http://schemas.xmlsoap.org/ws/2003/06/secext\""\
144 " xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\""\
145 " xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2002/12/policy\""\
146 " xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\""\
147 " xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\""\
148 " xmlns:wssc=\"http://schemas.xmlsoap.org/ws/2004/04/sc\""\
149 " xmlns:wst=\"http://schemas.xmlsoap.org/ws/2004/04/trust\">"\
151 MSN_SSO_AUTHINFO_TEMPLATE /* ps:AuthInfo */ \
153 "<EncryptedData xmlns=\"http://www.w3.org/2001/04/xmlenc#\" Id=\"BinaryDAToken0\" Type=\"http://www.w3.org/2001/04/xmlenc#Element\">"\
154 "<EncryptionMethod Algorithm=\"http://www.w3.org/2001/04/xmlenc#tripledes-cbc\"></EncryptionMethod>"\
155 "<ds:KeyInfo xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\">"\
156 "<ds:KeyName>http://Passport.NET/STS</ds:KeyName>"\
159 "<CipherValue>%s</CipherValue>"\
162 "<wssc:DerivedKeyToken Id=\"SignKey\">"\
163 "<wsse:RequestedTokenReference>"\
164 "<wsse:KeyIdentifier ValueType=\"http://docs.oasis-open.org/wss/2004/XX/oasis-2004XX-wss-saml-token-profile-1.0#SAMLAssertionID\" />"\
165 "<wsse:Reference URI=\"#BinaryDAToken0\" />"\
166 "</wsse:RequestedTokenReference>"\
167 "<wssc:Nonce>%s</wssc:Nonce>"\
168 "</wssc:DerivedKeyToken>"\
169 "%s" /* wsu:Timestamp */\
170 "<Signature xmlns=\"http://www.w3.org/2000/09/xmldsig#\">"\
171 "%s" /* SignedInfo */\
172 "<SignatureValue>%s</SignatureValue>"\
174 "<wsse:SecurityTokenReference>"\
175 "<wsse:Reference URI=\"#SignKey\" />"\
176 "</wsse:SecurityTokenReference>"\
182 "%s" /* wst:RequestSecurityToken */ \
186 typedef struct _MsnUsrKey MsnUsrKey;
189 int size; /* 28. Does not count data */
190 int crypt_mode; /* CRYPT_MODE_CBC (1) */
191 int cipher_type; /* TripleDES (0x6603) */
192 int hash_type; /* SHA1 (0x8004) */
194 int hash_len; /* 20 */
195 int cipher_len; /* 72 */
202 typedef struct _MsnTicketToken MsnTicketToken;
203 struct _MsnTicketToken {
210 typedef struct _MsnNexus MsnNexus;
216 /* From server via USR command */
220 /* From server via SOAP stuff */
223 MsnTicketToken *tokens;
227 void msn_nexus_connect(MsnNexus *nexus);
228 MsnNexus *msn_nexus_new(MsnSession *session);
229 void msn_nexus_destroy(MsnNexus *nexus);
230 GHashTable *msn_nexus_get_token(MsnNexus *nexus, MsnAuthDomains id);
231 const char *msn_nexus_get_token_str(MsnNexus *nexus, MsnAuthDomains id);
232 void msn_nexus_update_token(MsnNexus *nexus, int id, GSourceFunc cb, gpointer data);
233 #endif /* _MSN_NEXUS_H_ */