1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/Frameworks/libpurple.framework/Versions/0.6.2/Headers/nexus.h Fri Aug 21 13:25:11 2009 -0700
1.3 @@ -0,0 +1,234 @@
1.4 +/**
1.5 + * @file nexus.h MSN Nexus functions
1.6 + *
1.7 + * purple
1.8 + *
1.9 + * Purple is the legal property of its developers, whose names are too numerous
1.10 + * to list here. Please refer to the COPYRIGHT file distributed with this
1.11 + * source distribution.
1.12 + *
1.13 + * This program is free software; you can redistribute it and/or modify
1.14 + * it under the terms of the GNU General Public License as published by
1.15 + * the Free Software Foundation; either version 2 of the License, or
1.16 + * (at your option) any later version.
1.17 + *
1.18 + * This program is distributed in the hope that it will be useful,
1.19 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.20 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.21 + * GNU General Public License for more details.
1.22 + *
1.23 + * You should have received a copy of the GNU General Public License
1.24 + * along with this program; if not, write to the Free Software
1.25 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
1.26 + */
1.27 +#ifndef _MSN_NEXUS_H_
1.28 +#define _MSN_NEXUS_H_
1.29 +
1.30 +/* Index into ticket_tokens in nexus.c Keep updated! */
1.31 +typedef enum
1.32 +{
1.33 + MSN_AUTH_MESSENGER = 0,
1.34 + MSN_AUTH_MESSENGER_WEB = 1,
1.35 + MSN_AUTH_CONTACTS = 2,
1.36 + MSN_AUTH_LIVE_SECURE = 3,
1.37 + MSN_AUTH_SPACES = 4,
1.38 + MSN_AUTH_LIVE_CONTACTS = 5,
1.39 + MSN_AUTH_STORAGE = 6
1.40 +} MsnAuthDomains;
1.41 +
1.42 +#define MSN_SSO_SERVER "login.live.com"
1.43 +#define SSO_POST_URL "/RST.srf"
1.44 +
1.45 +#define MSN_SSO_RST_TEMPLATE \
1.46 +"<wst:RequestSecurityToken xmlns=\"http://schemas.xmlsoap.org/ws/2004/04/trust\" Id=\"RST%d\">"\
1.47 + "<wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>"\
1.48 + "<wsp:AppliesTo xmlns=\"http://schemas.xmlsoap.org/ws/2002/12/policy\">"\
1.49 + "<wsa:EndpointReference xmlns=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\">"\
1.50 + "<wsa:Address>%s</wsa:Address>"\
1.51 + "</wsa:EndpointReference>"\
1.52 + "</wsp:AppliesTo>"\
1.53 + "<wsse:PolicyReference xmlns=\"http://schemas.xmlsoap.org/ws/2003/06/secext\" URI=\"%s\"></wsse:PolicyReference>"\
1.54 +"</wst:RequestSecurityToken>"
1.55 +
1.56 +#define MSN_SSO_TEMPLATE "<?xml version='1.0' encoding='utf-8'?>"\
1.57 +"<Envelope xmlns=\"http://schemas.xmlsoap.org/soap/envelope/\""\
1.58 + " xmlns:wsse=\"http://schemas.xmlsoap.org/ws/2003/06/secext\""\
1.59 + " xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\""\
1.60 + " xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2002/12/policy\""\
1.61 + " xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\""\
1.62 + " xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\""\
1.63 + " xmlns:wssc=\"http://schemas.xmlsoap.org/ws/2004/04/sc\""\
1.64 + " xmlns:wst=\"http://schemas.xmlsoap.org/ws/2004/04/trust\">"\
1.65 + "<Header>"\
1.66 + "<ps:AuthInfo"\
1.67 + " xmlns:ps=\"http://schemas.microsoft.com/Passport/SoapServices/PPCRL\""\
1.68 + " Id=\"PPAuthInfo\">"\
1.69 + "<ps:HostingApp>{7108E71A-9926-4FCB-BCC9-9A9D3F32E423}</ps:HostingApp>"\
1.70 + "<ps:BinaryVersion>4</ps:BinaryVersion>"\
1.71 + "<ps:UIVersion>1</ps:UIVersion>"\
1.72 + "<ps:Cookies></ps:Cookies>"\
1.73 + "<ps:RequestParams>AQAAAAIAAABsYwQAAAAxMDMz</ps:RequestParams>"\
1.74 + "</ps:AuthInfo>"\
1.75 + "<wsse:Security>"\
1.76 + "<wsse:UsernameToken Id=\"user\">"\
1.77 + "<wsse:Username>%s</wsse:Username>"\
1.78 + "<wsse:Password>%s</wsse:Password>"\
1.79 + "</wsse:UsernameToken>"\
1.80 + "</wsse:Security>"\
1.81 + "</Header>"\
1.82 + "<Body>"\
1.83 + "<ps:RequestMultipleSecurityTokens"\
1.84 + " xmlns:ps=\"http://schemas.microsoft.com/Passport/SoapServices/PPCRL\""\
1.85 + " Id=\"RSTS\">"\
1.86 + "<wst:RequestSecurityToken Id=\"RST0\">"\
1.87 + "<wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>"\
1.88 + "<wsp:AppliesTo>"\
1.89 + "<wsa:EndpointReference>"\
1.90 + "<wsa:Address>http://Passport.NET/tb</wsa:Address>"\
1.91 + "</wsa:EndpointReference>"\
1.92 + "</wsp:AppliesTo>"\
1.93 + "</wst:RequestSecurityToken>"\
1.94 + "%s" /* Other RSTn tokens */\
1.95 + "</ps:RequestMultipleSecurityTokens>"\
1.96 + "</Body>"\
1.97 +"</Envelope>"
1.98 +
1.99 +#define MSN_SSO_AUTHINFO_TEMPLATE \
1.100 +"<ps:AuthInfo xmlns:ps=\"http://schemas.microsoft.com/Passport/SoapServices/PPCRL\" Id=\"PPAuthInfo\">"\
1.101 + "<ps:HostingApp>{7108E71A-9926-4FCB-BCC9-9A9D3F32E423}</ps:HostingApp>"\
1.102 + "<ps:BinaryVersion>4</ps:BinaryVersion>"\
1.103 + "<ps:UIVersion>1</ps:UIVersion>"\
1.104 + "<ps:Cookies></ps:Cookies>"\
1.105 + "<ps:RequestParams>AQAAAAIAAABsYwQAAAA0MTA1</ps:RequestParams>"\
1.106 +"</ps:AuthInfo>"
1.107 +/* Not sure what's editable here, so I'll just hard-code the SHA1 hash */
1.108 +#define MSN_SSO_AUTHINFO_SHA1_BASE64 "d2IeTF4DAkPEa/tVETHznsivEpc="
1.109 +
1.110 +#define MSN_SSO_TIMESTAMP_TEMPLATE \
1.111 +"<wsu:Timestamp xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" Id=\"Timestamp\">"\
1.112 + "<wsu:Created>%s</wsu:Created>"\
1.113 + "<wsu:Expires>%s</wsu:Expires>"\
1.114 +"</wsu:Timestamp>"
1.115 +
1.116 +#define MSN_SSO_SIGNEDINFO_TEMPLATE \
1.117 +"<SignedInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\">"\
1.118 + "<CanonicalizationMethod Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\"></CanonicalizationMethod>"\
1.119 + "<SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#hmac-sha1\"></SignatureMethod>"\
1.120 + "<Reference URI=\"#RST%d\">"\
1.121 + "<Transforms>"\
1.122 + "<Transform Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\"></Transform>"\
1.123 + "</Transforms>"\
1.124 + "<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"></DigestMethod>"\
1.125 + "<DigestValue>%s</DigestValue>"\
1.126 + "</Reference>"\
1.127 + "<Reference URI=\"#Timestamp\">"\
1.128 + "<Transforms>"\
1.129 + "<Transform Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\"></Transform>"\
1.130 + "</Transforms>"\
1.131 + "<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"></DigestMethod>"\
1.132 + "<DigestValue>%s</DigestValue>"\
1.133 + "</Reference>"\
1.134 + "<Reference URI=\"#PPAuthInfo\">"\
1.135 + "<Transforms>"\
1.136 + "<Transform Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\"></Transform>"\
1.137 + "</Transforms>"\
1.138 + "<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"></DigestMethod>"\
1.139 + "<DigestValue>" MSN_SSO_AUTHINFO_SHA1_BASE64 "</DigestValue>"\
1.140 + "</Reference>"\
1.141 +"</SignedInfo>"
1.142 +
1.143 +#define MSN_SSO_TOKEN_UPDATE_TEMPLATE "<?xml version=\"1.0\" encoding=\"utf-8\"?>"\
1.144 +"<Envelope"\
1.145 + " xmlns=\"http://schemas.xmlsoap.org/soap/envelope/\""\
1.146 + " xmlns:wsse=\"http://schemas.xmlsoap.org/ws/2003/06/secext\""\
1.147 + " xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\""\
1.148 + " xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2002/12/policy\""\
1.149 + " xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\""\
1.150 + " xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\""\
1.151 + " xmlns:wssc=\"http://schemas.xmlsoap.org/ws/2004/04/sc\""\
1.152 + " xmlns:wst=\"http://schemas.xmlsoap.org/ws/2004/04/trust\">"\
1.153 + "<Header>"\
1.154 + MSN_SSO_AUTHINFO_TEMPLATE /* ps:AuthInfo */ \
1.155 + "<wsse:Security>"\
1.156 + "<EncryptedData xmlns=\"http://www.w3.org/2001/04/xmlenc#\" Id=\"BinaryDAToken0\" Type=\"http://www.w3.org/2001/04/xmlenc#Element\">"\
1.157 + "<EncryptionMethod Algorithm=\"http://www.w3.org/2001/04/xmlenc#tripledes-cbc\"></EncryptionMethod>"\
1.158 + "<ds:KeyInfo xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\">"\
1.159 + "<ds:KeyName>http://Passport.NET/STS</ds:KeyName>"\
1.160 + "</ds:KeyInfo>"\
1.161 + "<CipherData>"\
1.162 + "<CipherValue>%s</CipherValue>"\
1.163 + "</CipherData>"\
1.164 + "</EncryptedData>"\
1.165 + "<wssc:DerivedKeyToken Id=\"SignKey\">"\
1.166 + "<wsse:RequestedTokenReference>"\
1.167 + "<wsse:KeyIdentifier ValueType=\"http://docs.oasis-open.org/wss/2004/XX/oasis-2004XX-wss-saml-token-profile-1.0#SAMLAssertionID\" />"\
1.168 + "<wsse:Reference URI=\"#BinaryDAToken0\" />"\
1.169 + "</wsse:RequestedTokenReference>"\
1.170 + "<wssc:Nonce>%s</wssc:Nonce>"\
1.171 + "</wssc:DerivedKeyToken>"\
1.172 + "%s" /* wsu:Timestamp */\
1.173 + "<Signature xmlns=\"http://www.w3.org/2000/09/xmldsig#\">"\
1.174 + "%s" /* SignedInfo */\
1.175 + "<SignatureValue>%s</SignatureValue>"\
1.176 + "<KeyInfo>"\
1.177 + "<wsse:SecurityTokenReference>"\
1.178 + "<wsse:Reference URI=\"#SignKey\" />"\
1.179 + "</wsse:SecurityTokenReference>"\
1.180 + "</KeyInfo>"\
1.181 + "</Signature>"\
1.182 + "</wsse:Security>"\
1.183 + "</Header>"\
1.184 + "<Body>"\
1.185 + "%s" /* wst:RequestSecurityToken */ \
1.186 + "</Body>"\
1.187 +"</Envelope>"
1.188 +
1.189 +typedef struct _MsnUsrKey MsnUsrKey;
1.190 +struct _MsnUsrKey
1.191 +{
1.192 + int size; /* 28. Does not count data */
1.193 + int crypt_mode; /* CRYPT_MODE_CBC (1) */
1.194 + int cipher_type; /* TripleDES (0x6603) */
1.195 + int hash_type; /* SHA1 (0x8004) */
1.196 + int iv_len; /* 8 */
1.197 + int hash_len; /* 20 */
1.198 + int cipher_len; /* 72 */
1.199 + /* Data */
1.200 + char iv[8];
1.201 + char hash[20];
1.202 + char cipher[72];
1.203 +};
1.204 +
1.205 +typedef struct _MsnTicketToken MsnTicketToken;
1.206 +struct _MsnTicketToken {
1.207 + GHashTable *token;
1.208 + char *secret;
1.209 + time_t expiry;
1.210 + GSList *updates;
1.211 +};
1.212 +
1.213 +typedef struct _MsnNexus MsnNexus;
1.214 +
1.215 +struct _MsnNexus
1.216 +{
1.217 + MsnSession *session;
1.218 +
1.219 + /* From server via USR command */
1.220 + char *policy;
1.221 + char *nonce;
1.222 +
1.223 + /* From server via SOAP stuff */
1.224 + char *cipher;
1.225 + char *secret;
1.226 + MsnTicketToken *tokens;
1.227 + int token_len;
1.228 +};
1.229 +
1.230 +void msn_nexus_connect(MsnNexus *nexus);
1.231 +MsnNexus *msn_nexus_new(MsnSession *session);
1.232 +void msn_nexus_destroy(MsnNexus *nexus);
1.233 +GHashTable *msn_nexus_get_token(MsnNexus *nexus, MsnAuthDomains id);
1.234 +const char *msn_nexus_get_token_str(MsnNexus *nexus, MsnAuthDomains id);
1.235 +void msn_nexus_update_token(MsnNexus *nexus, int id, GSourceFunc cb, gpointer data);
1.236 +#endif /* _MSN_NEXUS_H_ */
1.237 +