1
0

hashswf.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. /*
  2. * Copyright (C) 2009-2010 Howard Chu
  3. *
  4. * This file is part of librtmp.
  5. *
  6. * librtmp is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as
  8. * published by the Free Software Foundation; either version 2.1,
  9. * or (at your option) any later version.
  10. *
  11. * librtmp is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with librtmp see the file COPYING. If not, write to
  18. * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  19. * Boston, MA 02110-1301, USA.
  20. * http://www.gnu.org/copyleft/lgpl.html
  21. */
  22. #include "rtmp_sys.h"
  23. #include "log.h"
  24. #include "http.h"
  25. #ifdef CRYPTO
  26. #ifdef USE_POLARSSL
  27. #include <polarssl/sha2.h>
  28. #ifndef SHA256_DIGEST_LENGTH
  29. #define SHA256_DIGEST_LENGTH 32
  30. #endif
  31. #define HMAC_CTX sha2_context
  32. #define HMAC_setup(ctx, key, len) sha2_hmac_starts(&ctx, (unsigned char *)key, len, 0)
  33. #define HMAC_crunch(ctx, buf, len) sha2_hmac_update(&ctx, buf, len)
  34. #define HMAC_finish(ctx, dig, dlen) dlen = SHA256_DIGEST_LENGTH; sha2_hmac_finish(&ctx, dig)
  35. #define HMAC_close(ctx)
  36. #elif defined(USE_GNUTLS)
  37. #include <nettle/hmac.h>
  38. #ifndef SHA256_DIGEST_LENGTH
  39. #define SHA256_DIGEST_LENGTH 32
  40. #endif
  41. #undef HMAC_CTX
  42. #define HMAC_CTX struct hmac_sha256_ctx
  43. #define HMAC_setup(ctx, key, len) hmac_sha256_set_key(&ctx, len, key)
  44. #define HMAC_crunch(ctx, buf, len) hmac_sha256_update(&ctx, len, buf)
  45. #define HMAC_finish(ctx, dig, dlen) dlen = SHA256_DIGEST_LENGTH; hmac_sha256_digest(&ctx, SHA256_DIGEST_LENGTH, dig)
  46. #define HMAC_close(ctx)
  47. #else /* USE_OPENSSL */
  48. #include <openssl/ssl.h>
  49. #include <openssl/sha.h>
  50. #include <openssl/hmac.h>
  51. #include <openssl/rc4.h>
  52. #define HMAC_setup(ctx, key, len) HMAC_CTX_init(&ctx); HMAC_Init_ex(&ctx, (unsigned char *)key, len, EVP_sha256(), 0)
  53. #define HMAC_crunch(ctx, buf, len) HMAC_Update(&ctx, (unsigned char *)buf, len)
  54. #define HMAC_finish(ctx, dig, dlen) HMAC_Final(&ctx, (unsigned char *)dig, &dlen);
  55. #define HMAC_close(ctx) HMAC_CTX_cleanup(&ctx)
  56. #endif
  57. extern void RTMP_TLS_Init();
  58. extern TLS_CTX RTMP_TLS_ctx;
  59. #include <zlib.h>
  60. #endif /* CRYPTO */
  61. #define AGENT "Mozilla/5.0"
  62. HTTPResult
  63. HTTP_get(struct HTTP_ctx *http, const char *url, HTTP_read_callback *cb)
  64. {
  65. char *host, *path;
  66. char *p1, *p2;
  67. char hbuf[256];
  68. int port = 80;
  69. #ifdef CRYPTO
  70. int ssl = 0;
  71. #endif
  72. int hlen, flen = 0;
  73. int rc, i;
  74. int len_known;
  75. HTTPResult ret = HTTPRES_OK;
  76. struct sockaddr_in sa;
  77. RTMPSockBuf sb = {0};
  78. http->status = -1;
  79. memset(&sa, 0, sizeof(struct sockaddr_in));
  80. sa.sin_family = AF_INET;
  81. /* we only handle http here */
  82. if (strncasecmp(url, "http", 4))
  83. return HTTPRES_BAD_REQUEST;
  84. if (url[4] == 's')
  85. {
  86. #ifdef CRYPTO
  87. ssl = 1;
  88. port = 443;
  89. if (!RTMP_TLS_ctx)
  90. RTMP_TLS_Init();
  91. #else
  92. return HTTPRES_BAD_REQUEST;
  93. #endif
  94. }
  95. p1 = strchr(url + 4, ':');
  96. if (!p1 || strncmp(p1, "://", 3))
  97. return HTTPRES_BAD_REQUEST;
  98. host = p1 + 3;
  99. path = strchr(host, '/');
  100. hlen = path - host;
  101. strncpy(hbuf, host, hlen);
  102. hbuf[hlen] = '\0';
  103. host = hbuf;
  104. p1 = strrchr(host, ':');
  105. if (p1)
  106. {
  107. *p1++ = '\0';
  108. port = atoi(p1);
  109. }
  110. sa.sin_addr.s_addr = inet_addr(host);
  111. if (sa.sin_addr.s_addr == INADDR_NONE)
  112. {
  113. struct hostent *hp = gethostbyname(host);
  114. if (!hp || !hp->h_addr)
  115. return HTTPRES_LOST_CONNECTION;
  116. sa.sin_addr = *(struct in_addr *)hp->h_addr;
  117. }
  118. sa.sin_port = htons(port);
  119. sb.sb_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  120. if (sb.sb_socket == -1)
  121. return HTTPRES_LOST_CONNECTION;
  122. i =
  123. sprintf(sb.sb_buf,
  124. "GET %s HTTP/1.0\r\nUser-Agent: %s\r\nHost: %s\r\nReferer: %.*s\r\n",
  125. path, AGENT, host, (int)(path - url + 1), url);
  126. if (http->date[0])
  127. i += sprintf(sb.sb_buf + i, "If-Modified-Since: %s\r\n", http->date);
  128. i += sprintf(sb.sb_buf + i, "\r\n");
  129. if (connect
  130. (sb.sb_socket, (struct sockaddr *)&sa, sizeof(struct sockaddr)) < 0)
  131. {
  132. ret = HTTPRES_LOST_CONNECTION;
  133. goto leave;
  134. }
  135. #ifdef CRYPTO
  136. if (ssl)
  137. {
  138. #ifdef NO_SSL
  139. RTMP_Log(RTMP_LOGERROR, "%s, No SSL/TLS support", __FUNCTION__);
  140. ret = HTTPRES_BAD_REQUEST;
  141. goto leave;
  142. #else
  143. TLS_client(RTMP_TLS_ctx, sb.sb_ssl);
  144. TLS_setfd(sb.sb_ssl, sb.sb_socket);
  145. if (TLS_connect(sb.sb_ssl) < 0)
  146. {
  147. RTMP_Log(RTMP_LOGERROR, "%s, TLS_Connect failed", __FUNCTION__);
  148. ret = HTTPRES_LOST_CONNECTION;
  149. goto leave;
  150. }
  151. #endif
  152. }
  153. #endif
  154. RTMPSockBuf_Send(&sb, sb.sb_buf, i);
  155. /* set timeout */
  156. #define HTTP_TIMEOUT 5
  157. {
  158. SET_RCVTIMEO(tv, HTTP_TIMEOUT);
  159. if (setsockopt
  160. (sb.sb_socket, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv)))
  161. {
  162. RTMP_Log(RTMP_LOGERROR, "%s, Setting socket timeout to %ds failed!",
  163. __FUNCTION__, HTTP_TIMEOUT);
  164. }
  165. }
  166. sb.sb_size = 0;
  167. sb.sb_timedout = FALSE;
  168. if (RTMPSockBuf_Fill(&sb) < 1)
  169. {
  170. ret = HTTPRES_LOST_CONNECTION;
  171. goto leave;
  172. }
  173. if (strncmp(sb.sb_buf, "HTTP/1", 6))
  174. {
  175. ret = HTTPRES_BAD_REQUEST;
  176. goto leave;
  177. }
  178. p1 = strchr(sb.sb_buf, ' ');
  179. rc = atoi(p1 + 1);
  180. http->status = rc;
  181. if (rc >= 300)
  182. {
  183. if (rc == 304)
  184. {
  185. ret = HTTPRES_OK_NOT_MODIFIED;
  186. goto leave;
  187. }
  188. else if (rc == 404)
  189. ret = HTTPRES_NOT_FOUND;
  190. else if (rc >= 500)
  191. ret = HTTPRES_SERVER_ERROR;
  192. else if (rc >= 400)
  193. ret = HTTPRES_BAD_REQUEST;
  194. else
  195. ret = HTTPRES_REDIRECTED;
  196. }
  197. p1 = memchr(sb.sb_buf, '\n', sb.sb_size);
  198. if (!p1)
  199. {
  200. ret = HTTPRES_BAD_REQUEST;
  201. goto leave;
  202. }
  203. sb.sb_start = p1 + 1;
  204. sb.sb_size -= sb.sb_start - sb.sb_buf;
  205. while ((p2 = memchr(sb.sb_start, '\r', sb.sb_size)))
  206. {
  207. if (*sb.sb_start == '\r')
  208. {
  209. sb.sb_start += 2;
  210. sb.sb_size -= 2;
  211. break;
  212. }
  213. else if (!strncasecmp
  214. (sb.sb_start, "Content-Length: ", sizeof("Content-Length: ") - 1))
  215. {
  216. flen = atoi(sb.sb_start + sizeof("Content-Length: ") - 1);
  217. }
  218. else if (!strncasecmp
  219. (sb.sb_start, "Last-Modified: ", sizeof("Last-Modified: ") - 1))
  220. {
  221. *p2 = '\0';
  222. strcpy(http->date, sb.sb_start + sizeof("Last-Modified: ") - 1);
  223. }
  224. p2 += 2;
  225. sb.sb_size -= p2 - sb.sb_start;
  226. sb.sb_start = p2;
  227. if (sb.sb_size < 1)
  228. {
  229. if (RTMPSockBuf_Fill(&sb) < 1)
  230. {
  231. ret = HTTPRES_LOST_CONNECTION;
  232. goto leave;
  233. }
  234. }
  235. }
  236. len_known = flen > 0;
  237. while ((!len_known || flen > 0) &&
  238. (sb.sb_size > 0 || RTMPSockBuf_Fill(&sb) > 0))
  239. {
  240. cb(sb.sb_start, 1, sb.sb_size, http->data);
  241. if (len_known)
  242. flen -= sb.sb_size;
  243. http->size += sb.sb_size;
  244. sb.sb_size = 0;
  245. }
  246. if (flen > 0)
  247. ret = HTTPRES_LOST_CONNECTION;
  248. leave:
  249. RTMPSockBuf_Close(&sb);
  250. return ret;
  251. }
  252. #ifdef CRYPTO
  253. #define CHUNK 16384
  254. struct info
  255. {
  256. z_stream *zs;
  257. HMAC_CTX ctx;
  258. int first;
  259. int zlib;
  260. int size;
  261. };
  262. static size_t
  263. swfcrunch(void *ptr, size_t size, size_t nmemb, void *stream)
  264. {
  265. struct info *i = stream;
  266. char *p = ptr;
  267. size_t len = size * nmemb;
  268. if (i->first)
  269. {
  270. i->first = 0;
  271. /* compressed? */
  272. if (!strncmp(p, "CWS", 3))
  273. {
  274. *p = 'F';
  275. i->zlib = 1;
  276. }
  277. HMAC_crunch(i->ctx, (unsigned char *)p, 8);
  278. p += 8;
  279. len -= 8;
  280. i->size = 8;
  281. }
  282. if (i->zlib)
  283. {
  284. unsigned char out[CHUNK];
  285. i->zs->next_in = (unsigned char *)p;
  286. i->zs->avail_in = len;
  287. do
  288. {
  289. i->zs->avail_out = CHUNK;
  290. i->zs->next_out = out;
  291. inflate(i->zs, Z_NO_FLUSH);
  292. len = CHUNK - i->zs->avail_out;
  293. i->size += len;
  294. HMAC_crunch(i->ctx, out, len);
  295. }
  296. while (i->zs->avail_out == 0);
  297. }
  298. else
  299. {
  300. i->size += len;
  301. HMAC_crunch(i->ctx, (unsigned char *)p, len);
  302. }
  303. return size * nmemb;
  304. }
  305. static int tzoff;
  306. static int tzchecked;
  307. #define JAN02_1980 318340800
  308. static const char *monthtab[12] = { "Jan", "Feb", "Mar",
  309. "Apr", "May", "Jun",
  310. "Jul", "Aug", "Sep",
  311. "Oct", "Nov", "Dec"
  312. };
  313. static const char *days[] =
  314. { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
  315. /* Parse an HTTP datestamp into Unix time */
  316. static time_t
  317. make_unix_time(char *s)
  318. {
  319. struct tm time;
  320. int i, ysub = 1900, fmt = 0;
  321. char *month;
  322. char *n;
  323. time_t res;
  324. if (s[3] != ' ')
  325. {
  326. fmt = 1;
  327. if (s[3] != ',')
  328. ysub = 0;
  329. }
  330. for (n = s; *n; ++n)
  331. if (*n == '-' || *n == ':')
  332. *n = ' ';
  333. time.tm_mon = 0;
  334. n = strchr(s, ' ');
  335. if (fmt)
  336. {
  337. /* Day, DD-MMM-YYYY HH:MM:SS GMT */
  338. time.tm_mday = strtol(n + 1, &n, 0);
  339. month = n + 1;
  340. n = strchr(month, ' ');
  341. time.tm_year = strtol(n + 1, &n, 0);
  342. time.tm_hour = strtol(n + 1, &n, 0);
  343. time.tm_min = strtol(n + 1, &n, 0);
  344. time.tm_sec = strtol(n + 1, NULL, 0);
  345. }
  346. else
  347. {
  348. /* Unix ctime() format. Does not conform to HTTP spec. */
  349. /* Day MMM DD HH:MM:SS YYYY */
  350. month = n + 1;
  351. n = strchr(month, ' ');
  352. while (isspace(*n))
  353. n++;
  354. time.tm_mday = strtol(n, &n, 0);
  355. time.tm_hour = strtol(n + 1, &n, 0);
  356. time.tm_min = strtol(n + 1, &n, 0);
  357. time.tm_sec = strtol(n + 1, &n, 0);
  358. time.tm_year = strtol(n + 1, NULL, 0);
  359. }
  360. if (time.tm_year > 100)
  361. time.tm_year -= ysub;
  362. for (i = 0; i < 12; i++)
  363. if (!strncasecmp(month, monthtab[i], 3))
  364. {
  365. time.tm_mon = i;
  366. break;
  367. }
  368. time.tm_isdst = 0; /* daylight saving is never in effect in GMT */
  369. /* this is normally the value of extern int timezone, but some
  370. * braindead C libraries don't provide it.
  371. */
  372. if (!tzchecked)
  373. {
  374. struct tm *tc;
  375. time_t then = JAN02_1980;
  376. tc = localtime(&then);
  377. tzoff = (12 - tc->tm_hour) * 3600 + tc->tm_min * 60 + tc->tm_sec;
  378. tzchecked = 1;
  379. }
  380. res = mktime(&time);
  381. /* Unfortunately, mktime() assumes the input is in local time,
  382. * not GMT, so we have to correct it here.
  383. */
  384. if (res != -1)
  385. res += tzoff;
  386. return res;
  387. }
  388. /* Convert a Unix time to a network time string
  389. * Weekday, DD-MMM-YYYY HH:MM:SS GMT
  390. */
  391. static void
  392. strtime(time_t * t, char *s)
  393. {
  394. struct tm *tm;
  395. tm = gmtime((time_t *) t);
  396. sprintf(s, "%s, %02d %s %d %02d:%02d:%02d GMT",
  397. days[tm->tm_wday], tm->tm_mday, monthtab[tm->tm_mon],
  398. tm->tm_year + 1900, tm->tm_hour, tm->tm_min, tm->tm_sec);
  399. }
  400. #define HEX2BIN(a) (((a)&0x40)?((a)&0xf)+9:((a)&0xf))
  401. int
  402. RTMP_HashSWF(const char *url, unsigned int *size, unsigned char *hash,
  403. int age)
  404. {
  405. FILE *f = NULL;
  406. char *path, date[64], cctim[64];
  407. long pos = 0;
  408. time_t ctim = -1, cnow;
  409. int i, got = 0, ret = 0;
  410. unsigned int hlen;
  411. struct info in = { 0 };
  412. struct HTTP_ctx http = { 0 };
  413. HTTPResult httpres;
  414. z_stream zs = { 0 };
  415. AVal home, hpre;
  416. date[0] = '\0';
  417. #ifdef _WIN32
  418. #ifdef XBMC4XBOX
  419. hpre.av_val = "Q:";
  420. hpre.av_len = 2;
  421. home.av_val = "\\UserData";
  422. #else
  423. hpre.av_val = getenv("HOMEDRIVE");
  424. hpre.av_len = strlen(hpre.av_val);
  425. home.av_val = getenv("HOMEPATH");
  426. #endif
  427. #define DIRSEP "\\"
  428. #else /* !_WIN32 */
  429. hpre.av_val = "";
  430. hpre.av_len = 0;
  431. home.av_val = getenv("HOME");
  432. #define DIRSEP "/"
  433. #endif
  434. if (!home.av_val)
  435. home.av_val = ".";
  436. home.av_len = strlen(home.av_val);
  437. /* SWF hash info is cached in a fixed-format file.
  438. * url: <url of SWF file>
  439. * ctim: HTTP datestamp of when we last checked it.
  440. * date: HTTP datestamp of the SWF's last modification.
  441. * size: SWF size in hex
  442. * hash: SWF hash in hex
  443. *
  444. * These fields must be present in this order. All fields
  445. * besides URL are fixed size.
  446. */
  447. path = malloc(hpre.av_len + home.av_len + sizeof(DIRSEP ".swfinfo"));
  448. sprintf(path, "%s%s" DIRSEP ".swfinfo", hpre.av_val, home.av_val);
  449. f = fopen(path, "r+");
  450. while (f)
  451. {
  452. char buf[4096], *file, *p;
  453. file = strchr(url, '/');
  454. if (!file)
  455. break;
  456. file += 2;
  457. file = strchr(file, '/');
  458. if (!file)
  459. break;
  460. file++;
  461. hlen = file - url;
  462. p = strrchr(file, '/');
  463. if (p)
  464. file = p;
  465. else
  466. file--;
  467. while (fgets(buf, sizeof(buf), f))
  468. {
  469. char *r1;
  470. got = 0;
  471. if (strncmp(buf, "url: ", 5))
  472. continue;
  473. if (strncmp(buf + 5, url, hlen))
  474. continue;
  475. r1 = strrchr(buf, '/');
  476. i = strlen(r1);
  477. r1[--i] = '\0';
  478. if (strncmp(r1, file, i))
  479. continue;
  480. pos = ftell(f);
  481. while (got < 4 && fgets(buf, sizeof(buf), f))
  482. {
  483. if (!strncmp(buf, "size: ", 6))
  484. {
  485. *size = strtol(buf + 6, NULL, 16);
  486. got++;
  487. }
  488. else if (!strncmp(buf, "hash: ", 6))
  489. {
  490. unsigned char *ptr = hash, *in = (unsigned char *)buf + 6;
  491. int l = strlen((char *)in) - 1;
  492. for (i = 0; i < l; i += 2)
  493. *ptr++ = (HEX2BIN(in[i]) << 4) | HEX2BIN(in[i + 1]);
  494. got++;
  495. }
  496. else if (!strncmp(buf, "date: ", 6))
  497. {
  498. buf[strlen(buf) - 1] = '\0';
  499. strncpy(date, buf + 6, sizeof(date));
  500. got++;
  501. }
  502. else if (!strncmp(buf, "ctim: ", 6))
  503. {
  504. buf[strlen(buf) - 1] = '\0';
  505. ctim = make_unix_time(buf + 6);
  506. got++;
  507. }
  508. else if (!strncmp(buf, "url: ", 5))
  509. break;
  510. }
  511. break;
  512. }
  513. break;
  514. }
  515. cnow = time(NULL);
  516. /* If we got a cache time, see if it's young enough to use directly */
  517. if (age && ctim > 0)
  518. {
  519. ctim = cnow - ctim;
  520. ctim /= 3600 * 24; /* seconds to days */
  521. if (ctim < age) /* ok, it's new enough */
  522. goto out;
  523. }
  524. in.first = 1;
  525. HMAC_setup(in.ctx, "Genuine Adobe Flash Player 001", 30);
  526. inflateInit(&zs);
  527. in.zs = &zs;
  528. http.date = date;
  529. http.data = &in;
  530. httpres = HTTP_get(&http, url, swfcrunch);
  531. inflateEnd(&zs);
  532. if (httpres != HTTPRES_OK && httpres != HTTPRES_OK_NOT_MODIFIED)
  533. {
  534. ret = -1;
  535. if (httpres == HTTPRES_LOST_CONNECTION)
  536. RTMP_Log(RTMP_LOGERROR, "%s: connection lost while downloading swfurl %s",
  537. __FUNCTION__, url);
  538. else if (httpres == HTTPRES_NOT_FOUND)
  539. RTMP_Log(RTMP_LOGERROR, "%s: swfurl %s not found", __FUNCTION__, url);
  540. else
  541. RTMP_Log(RTMP_LOGERROR, "%s: couldn't contact swfurl %s (HTTP error %d)",
  542. __FUNCTION__, url, http.status);
  543. }
  544. else
  545. {
  546. if (got && pos)
  547. fseek(f, pos, SEEK_SET);
  548. else
  549. {
  550. char *q;
  551. if (!f)
  552. f = fopen(path, "w");
  553. if (!f)
  554. {
  555. int err = errno;
  556. RTMP_Log(RTMP_LOGERROR,
  557. "%s: couldn't open %s for writing, errno %d (%s)",
  558. __FUNCTION__, path, err, strerror(err));
  559. ret = -1;
  560. goto out;
  561. }
  562. fseek(f, 0, SEEK_END);
  563. q = strchr(url, '?');
  564. if (q)
  565. i = q - url;
  566. else
  567. i = strlen(url);
  568. fprintf(f, "url: %.*s\n", i, url);
  569. }
  570. strtime(&cnow, cctim);
  571. fprintf(f, "ctim: %s\n", cctim);
  572. if (!in.first)
  573. {
  574. HMAC_finish(in.ctx, hash, hlen);
  575. *size = in.size;
  576. fprintf(f, "date: %s\n", date);
  577. fprintf(f, "size: %08x\n", in.size);
  578. fprintf(f, "hash: ");
  579. for (i = 0; i < SHA256_DIGEST_LENGTH; i++)
  580. fprintf(f, "%02x", hash[i]);
  581. fprintf(f, "\n");
  582. }
  583. }
  584. HMAC_close(in.ctx);
  585. out:
  586. free(path);
  587. if (f)
  588. fclose(f);
  589. return ret;
  590. }
  591. #else
  592. int
  593. RTMP_HashSWF(const char *url, unsigned int *size, unsigned char *hash,
  594. int age)
  595. {
  596. (void)url;
  597. (void)size;
  598. (void)hash;
  599. (void)age;
  600. return -1;
  601. }
  602. #endif