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 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853
|
<pre>Internet Engineering Task Force (IETF) M. Jones
Request for Comments: 7516 Microsoft
Category: Standards Track J. Hildebrand
ISSN: 2070-1721 Cisco
May 2015
<span class="h1">JSON Web Encryption (JWE)</span>
Abstract
JSON Web Encryption (JWE) represents encrypted content using
JSON-based data structures. Cryptographic algorithms and identifiers
for use with this specification are described in the separate JSON
Web Algorithms (JWA) specification and IANA registries defined by
that specification. Related digital signature and Message
Authentication Code (MAC) capabilities are described in the separate
JSON Web Signature (JWS) specification.
Status of This Memo
This is an Internet Standards Track document.
This document is a product of the Internet Engineering Task Force
(IETF). It represents the consensus of the IETF community. It has
received public review and has been approved for publication by the
Internet Engineering Steering Group (IESG). Further information on
Internet Standards is available in <a href="./rfc5741#section-2">Section 2 of RFC 5741</a>.
Information about the current status of this document, any errata,
and how to provide feedback on it may be obtained at
<a href="http://www.rfc-editor.org/info/rfc7516">http://www.rfc-editor.org/info/rfc7516</a>.
Copyright Notice
Copyright (c) 2015 IETF Trust and the persons identified as the
document authors. All rights reserved.
This document is subject to <a href="https://www.rfc-editor.org/bcp/bcp78">BCP 78</a> and the IETF Trust's Legal
Provisions Relating to IETF Documents
(<a href="http://trustee.ietf.org/license-info">http://trustee.ietf.org/license-info</a>) in effect on the date of
publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with respect
to this document. Code Components extracted from this document must
include Simplified BSD License text as described in Section 4.e of
the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License.
<span class="grey">Jones & Hildebrand Standards Track [Page 1]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-2" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
Table of Contents
<a href="#section-1">1</a>. Introduction . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-4">4</a>
<a href="#section-1.1">1.1</a>. Notational Conventions . . . . . . . . . . . . . . . . . <a href="#page-4">4</a>
<a href="#section-2">2</a>. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-5">5</a>
<a href="#section-3">3</a>. JSON Web Encryption (JWE) Overview . . . . . . . . . . . . . <a href="#page-8">8</a>
<a href="#section-3.1">3.1</a>. JWE Compact Serialization Overview . . . . . . . . . . . <a href="#page-8">8</a>
<a href="#section-3.2">3.2</a>. JWE JSON Serialization Overview . . . . . . . . . . . . . <a href="#page-9">9</a>
<a href="#section-3.3">3.3</a>. Example JWE . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-10">10</a>
<a href="#section-4">4</a>. JOSE Header . . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-11">11</a>
<a href="#section-4.1">4.1</a>. Registered Header Parameter Names . . . . . . . . . . . . <a href="#page-11">11</a>
<a href="#section-4.1.1">4.1.1</a>. "alg" (Algorithm) Header Parameter . . . . . . . . . <a href="#page-12">12</a>
<a href="#section-4.1.2">4.1.2</a>. "enc" (Encryption Algorithm) Header Parameter . . . . <a href="#page-12">12</a>
<a href="#section-4.1.3">4.1.3</a>. "zip" (Compression Algorithm) Header Parameter . . . <a href="#page-12">12</a>
<a href="#section-4.1.4">4.1.4</a>. "jku" (JWK Set URL) Header Parameter . . . . . . . . <a href="#page-13">13</a>
<a href="#section-4.1.5">4.1.5</a>. "jwk" (JSON Web Key) Header Parameter . . . . . . . . <a href="#page-13">13</a>
<a href="#section-4.1.6">4.1.6</a>. "kid" (Key ID) Header Parameter . . . . . . . . . . . <a href="#page-13">13</a>
<a href="#section-4.1.7">4.1.7</a>. "x5u" (X.509 URL) Header Parameter . . . . . . . . . <a href="#page-13">13</a>
<a href="#section-4.1.8">4.1.8</a>. "x5c" (X.509 Certificate Chain) Header Parameter . . <a href="#page-13">13</a>
4.1.9. "x5t" (X.509 Certificate SHA-1 Thumbprint) Header
Parameter . . . . . . . . . . . . . . . . . . . . . . <a href="#page-14">14</a>
4.1.10. "x5t#S256" (X.509 Certificate SHA-256 Thumbprint)
Header Parameter . . . . . . . . . . . . . . . . . . <a href="#page-14">14</a>
<a href="#section-4.1.11">4.1.11</a>. "typ" (Type) Header Parameter . . . . . . . . . . . . <a href="#page-14">14</a>
<a href="#section-4.1.12">4.1.12</a>. "cty" (Content Type) Header Parameter . . . . . . . . <a href="#page-14">14</a>
<a href="#section-4.1.13">4.1.13</a>. "crit" (Critical) Header Parameter . . . . . . . . . <a href="#page-14">14</a>
<a href="#section-4.2">4.2</a>. Public Header Parameter Names . . . . . . . . . . . . . . <a href="#page-14">14</a>
<a href="#section-4.3">4.3</a>. Private Header Parameter Names . . . . . . . . . . . . . <a href="#page-15">15</a>
<a href="#section-5">5</a>. Producing and Consuming JWEs . . . . . . . . . . . . . . . . <a href="#page-15">15</a>
<a href="#section-5.1">5.1</a>. Message Encryption . . . . . . . . . . . . . . . . . . . <a href="#page-15">15</a>
<a href="#section-5.2">5.2</a>. Message Decryption . . . . . . . . . . . . . . . . . . . <a href="#page-17">17</a>
<a href="#section-5.3">5.3</a>. String Comparison Rules . . . . . . . . . . . . . . . . . <a href="#page-20">20</a>
<a href="#section-6">6</a>. Key Identification . . . . . . . . . . . . . . . . . . . . . <a href="#page-20">20</a>
<a href="#section-7">7</a>. Serializations . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-20">20</a>
<a href="#section-7.1">7.1</a>. JWE Compact Serialization . . . . . . . . . . . . . . . . <a href="#page-20">20</a>
<a href="#section-7.2">7.2</a>. JWE JSON Serialization . . . . . . . . . . . . . . . . . <a href="#page-20">20</a>
<a href="#section-7.2.1">7.2.1</a>. General JWE JSON Serialization Syntax . . . . . . . . <a href="#page-21">21</a>
<a href="#section-7.2.2">7.2.2</a>. Flattened JWE JSON Serialization Syntax . . . . . . . <a href="#page-23">23</a>
<a href="#section-8">8</a>. TLS Requirements . . . . . . . . . . . . . . . . . . . . . . <a href="#page-24">24</a>
<a href="#section-9">9</a>. Distinguishing between JWS and JWE Objects . . . . . . . . . <a href="#page-24">24</a>
<a href="#section-10">10</a>. IANA Considerations . . . . . . . . . . . . . . . . . . . . . <a href="#page-25">25</a>
10.1. JSON Web Signature and Encryption Header Parameters
Registration . . . . . . . . . . . . . . . . . . . . . . <a href="#page-25">25</a>
<a href="#section-10.1.1">10.1.1</a>. Registry Contents . . . . . . . . . . . . . . . . . <a href="#page-25">25</a>
<a href="#section-11">11</a>. Security Considerations . . . . . . . . . . . . . . . . . . . <a href="#page-27">27</a>
<a href="#section-11.1">11.1</a>. Key Entropy and Random Values . . . . . . . . . . . . . <a href="#page-27">27</a>
<a href="#section-11.2">11.2</a>. Key Protection . . . . . . . . . . . . . . . . . . . . . <a href="#page-27">27</a>
<a href="#section-11.3">11.3</a>. Using Matching Algorithm Strengths . . . . . . . . . . . <a href="#page-28">28</a>
<span class="grey">Jones & Hildebrand Standards Track [Page 2]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-3" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
<a href="#section-11.4">11.4</a>. Adaptive Chosen-Ciphertext Attacks . . . . . . . . . . . <a href="#page-28">28</a>
<a href="#section-11.5">11.5</a>. Timing Attacks . . . . . . . . . . . . . . . . . . . . . <a href="#page-28">28</a>
<a href="#section-12">12</a>. References . . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-29">29</a>
<a href="#section-12.1">12.1</a>. Normative References . . . . . . . . . . . . . . . . . . <a href="#page-29">29</a>
<a href="#section-12.2">12.2</a>. Informative References . . . . . . . . . . . . . . . . . <a href="#page-30">30</a>
<a href="#appendix-A">Appendix A</a>. JWE Examples . . . . . . . . . . . . . . . . . . . . <a href="#page-32">32</a>
<a href="#appendix-A.1">A.1</a>. Example JWE using RSAES-OAEP and AES GCM . . . . . . . . <a href="#page-32">32</a>
<a href="#appendix-A.1.1">A.1.1</a>. JOSE Header . . . . . . . . . . . . . . . . . . . . . <a href="#page-32">32</a>
<a href="#appendix-A.1.2">A.1.2</a>. Content Encryption Key (CEK) . . . . . . . . . . . . <a href="#page-32">32</a>
<a href="#appendix-A.1.3">A.1.3</a>. Key Encryption . . . . . . . . . . . . . . . . . . . <a href="#page-33">33</a>
<a href="#appendix-A.1.4">A.1.4</a>. Initialization Vector . . . . . . . . . . . . . . . . <a href="#page-34">34</a>
<a href="#appendix-A.1.5">A.1.5</a>. Additional Authenticated Data . . . . . . . . . . . . <a href="#page-35">35</a>
<a href="#appendix-A.1.6">A.1.6</a>. Content Encryption . . . . . . . . . . . . . . . . . <a href="#page-35">35</a>
<a href="#appendix-A.1.7">A.1.7</a>. Complete Representation . . . . . . . . . . . . . . . <a href="#page-36">36</a>
<a href="#appendix-A.1.8">A.1.8</a>. Validation . . . . . . . . . . . . . . . . . . . . . <a href="#page-36">36</a>
A.2. Example JWE using RSAES-PKCS1-v1_5 and
AES_128_CBC_HMAC_SHA_256 . . . . . . . . . . . . . . . . <a href="#page-36">36</a>
<a href="#appendix-A.2.1">A.2.1</a>. JOSE Header . . . . . . . . . . . . . . . . . . . . . <a href="#page-37">37</a>
<a href="#appendix-A.2.2">A.2.2</a>. Content Encryption Key (CEK) . . . . . . . . . . . . <a href="#page-37">37</a>
<a href="#appendix-A.2.3">A.2.3</a>. Key Encryption . . . . . . . . . . . . . . . . . . . <a href="#page-38">38</a>
<a href="#appendix-A.2.4">A.2.4</a>. Initialization Vector . . . . . . . . . . . . . . . . <a href="#page-39">39</a>
<a href="#appendix-A.2.5">A.2.5</a>. Additional Authenticated Data . . . . . . . . . . . . <a href="#page-40">40</a>
<a href="#appendix-A.2.6">A.2.6</a>. Content Encryption . . . . . . . . . . . . . . . . . <a href="#page-40">40</a>
<a href="#appendix-A.2.7">A.2.7</a>. Complete Representation . . . . . . . . . . . . . . . <a href="#page-40">40</a>
<a href="#appendix-A.2.8">A.2.8</a>. Validation . . . . . . . . . . . . . . . . . . . . . <a href="#page-41">41</a>
A.3. Example JWE Using AES Key Wrap and
AES_128_CBC_HMAC_SHA_256 . . . . . . . . . . . . . . . . <a href="#page-41">41</a>
<a href="#appendix-A.3.1">A.3.1</a>. JOSE Header . . . . . . . . . . . . . . . . . . . . . <a href="#page-41">41</a>
<a href="#appendix-A.3.2">A.3.2</a>. Content Encryption Key (CEK) . . . . . . . . . . . . <a href="#page-42">42</a>
<a href="#appendix-A.3.3">A.3.3</a>. Key Encryption . . . . . . . . . . . . . . . . . . . <a href="#page-42">42</a>
<a href="#appendix-A.3.4">A.3.4</a>. Initialization Vector . . . . . . . . . . . . . . . . <a href="#page-42">42</a>
<a href="#appendix-A.3.5">A.3.5</a>. Additional Authenticated Data . . . . . . . . . . . . <a href="#page-43">43</a>
<a href="#appendix-A.3.6">A.3.6</a>. Content Encryption . . . . . . . . . . . . . . . . . <a href="#page-43">43</a>
<a href="#appendix-A.3.7">A.3.7</a>. Complete Representation . . . . . . . . . . . . . . . <a href="#page-43">43</a>
<a href="#appendix-A.3.8">A.3.8</a>. Validation . . . . . . . . . . . . . . . . . . . . . <a href="#page-44">44</a>
<a href="#appendix-A.4">A.4</a>. Example JWE Using General JWE JSON Serialization . . . . <a href="#page-44">44</a>
<a href="#appendix-A.4.1">A.4.1</a>. JWE Per-Recipient Unprotected Headers . . . . . . . . <a href="#page-45">45</a>
<a href="#appendix-A.4.2">A.4.2</a>. JWE Protected Header . . . . . . . . . . . . . . . . <a href="#page-45">45</a>
<a href="#appendix-A.4.3">A.4.3</a>. JWE Shared Unprotected Header . . . . . . . . . . . . <a href="#page-45">45</a>
<a href="#appendix-A.4.4">A.4.4</a>. Complete JOSE Header Values . . . . . . . . . . . . . <a href="#page-45">45</a>
<a href="#appendix-A.4.5">A.4.5</a>. Additional Authenticated Data . . . . . . . . . . . . <a href="#page-46">46</a>
<a href="#appendix-A.4.6">A.4.6</a>. Content Encryption . . . . . . . . . . . . . . . . . <a href="#page-46">46</a>
<a href="#appendix-A.4.7">A.4.7</a>. Complete JWE JSON Serialization Representation . . . <a href="#page-47">47</a>
<a href="#appendix-A.5">A.5</a>. Example JWE Using Flattened JWE JSON Serialization . . . <a href="#page-47">47</a>
<a href="#appendix-B">Appendix B</a>. Example AES_128_CBC_HMAC_SHA_256 Computation . . . . <a href="#page-48">48</a>
<a href="#appendix-B.1">B.1</a>. Extract MAC_KEY and ENC_KEY from Key . . . . . . . . . . <a href="#page-48">48</a>
<a href="#appendix-B.2">B.2</a>. Encrypt Plaintext to Create Ciphertext . . . . . . . . . <a href="#page-49">49</a>
<a href="#appendix-B.3">B.3</a>. 64-Bit Big-Endian Representation of AAD Length . . . . . <a href="#page-49">49</a>
<span class="grey">Jones & Hildebrand Standards Track [Page 3]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-4" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
<a href="#appendix-B.4">B.4</a>. Initialization Vector Value . . . . . . . . . . . . . . . <a href="#page-49">49</a>
<a href="#appendix-B.5">B.5</a>. Create Input to HMAC Computation . . . . . . . . . . . . <a href="#page-50">50</a>
<a href="#appendix-B.6">B.6</a>. Compute HMAC Value . . . . . . . . . . . . . . . . . . . <a href="#page-50">50</a>
<a href="#appendix-B.7">B.7</a>. Truncate HMAC Value to Create Authentication Tag . . . . <a href="#page-50">50</a>
Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-50">50</a>
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-51">51</a>
<span class="h2"><a class="selflink" id="section-1" href="#section-1">1</a>. Introduction</span>
JSON Web Encryption (JWE) represents encrypted content using JSON-
based data structures [<a href="./rfc7159" title=""The JavaScript Object Notation (JSON) Data Interchange Format"">RFC7159</a>]. The JWE cryptographic mechanisms
encrypt and provide integrity protection for an arbitrary sequence of
octets.
Two closely related serializations for JWEs are defined. The JWE
Compact Serialization is a compact, URL-safe representation intended
for space constrained environments such as HTTP Authorization headers
and URI query parameters. The JWE JSON Serialization represents JWEs
as JSON objects and enables the same content to be encrypted to
multiple parties. Both share the same cryptographic underpinnings.
Cryptographic algorithms and identifiers for use with this
specification are described in the separate JSON Web Algorithms (JWA)
[<a href="#ref-JWA" title=""JSON Web Algorithms (JWA)"">JWA</a>] specification and IANA registries defined by that
specification. Related digital signature and MAC capabilities are
described in the separate JSON Web Signature (JWS) [<a href="#ref-JWS" title=""JSON Web Signature (JWS)"">JWS</a>]
specification.
Names defined by this specification are short because a core goal is
for the resulting representations to be compact.
<span class="h3"><a class="selflink" id="section-1.1" href="#section-1.1">1.1</a>. Notational Conventions</span>
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
"OPTIONAL" in this document are to be interpreted as described in
"Key words for use in RFCs to Indicate Requirement Levels" [<a href="./rfc2119" title=""Key words for use in RFCs to Indicate Requirement Levels"">RFC2119</a>].
The interpretation should only be applied when the terms appear in
all capital letters.
BASE64URL(OCTETS) denotes the base64url encoding of OCTETS, per
Section 2 of [<a href="#ref-JWS" title=""JSON Web Signature (JWS)"">JWS</a>].
UTF8(STRING) denotes the octets of the UTF-8 [<a href="./rfc3629" title=""UTF-8, a transformation format of ISO 10646"">RFC3629</a>] representation
of STRING, where STRING is a sequence of zero or more Unicode
[<a href="#ref-UNICODE" title=""The Unicode Standard"">UNICODE</a>] characters.
<span class="grey">Jones & Hildebrand Standards Track [Page 4]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-5" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
ASCII(STRING) denotes the octets of the ASCII [<a href="./rfc20" title=""ASCII format for Network Interchange"">RFC20</a>] representation
of STRING, where STRING is a sequence of zero or more ASCII
characters.
The concatenation of two values A and B is denoted as A || B.
<span class="h2"><a class="selflink" id="section-2" href="#section-2">2</a>. Terminology</span>
The terms "JSON Web Signature (JWS)", "Base64url Encoding",
"Collision-Resistant Name", "Header Parameter", "JOSE Header", and
"StringOrURI" are defined by the JWS specification [<a href="#ref-JWS" title=""JSON Web Signature (JWS)"">JWS</a>].
The terms "Ciphertext", "Digital Signature", "Initialization Vector
(IV)", "Message Authentication Code (MAC)", and "Plaintext" are
defined by the "Internet Security Glossary, Version 2" [<a href="./rfc4949" title=""Internet Security Glossary, Version 2"">RFC4949</a>].
These terms are defined by this specification:
JSON Web Encryption (JWE)
A data structure representing an encrypted and integrity-protected
message.
Authenticated Encryption with Associated Data (AEAD)
An AEAD algorithm is one that encrypts the plaintext, allows
Additional Authenticated Data to be specified, and provides an
integrated content integrity check over the ciphertext and
Additional Authenticated Data. AEAD algorithms accept two inputs,
the plaintext and the Additional Authenticated Data value, and
produce two outputs, the ciphertext and the Authentication Tag
value. AES Galois/Counter Mode (GCM) is one such algorithm.
Additional Authenticated Data (AAD)
An input to an AEAD operation that is integrity protected but not
encrypted.
Authentication Tag
An output of an AEAD operation that ensures the integrity of the
ciphertext and the Additional Authenticated Data. Note that some
algorithms may not use an Authentication Tag, in which case this
value is the empty octet sequence.
Content Encryption Key (CEK)
A symmetric key for the AEAD algorithm used to encrypt the
plaintext to produce the ciphertext and the Authentication Tag.
<span class="grey">Jones & Hildebrand Standards Track [Page 5]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-6" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
JWE Encrypted Key
Encrypted Content Encryption Key value. Note that for some
algorithms, the JWE Encrypted Key value is specified as being the
empty octet sequence.
JWE Initialization Vector
Initialization Vector value used when encrypting the plaintext.
Note that some algorithms may not use an Initialization Vector, in
which case this value is the empty octet sequence.
JWE AAD
Additional value to be integrity protected by the authenticated
encryption operation. This can only be present when using the JWE
JSON Serialization. (Note that this can also be achieved when
using either the JWE Compact Serialization or the JWE JSON
Serialization by including the AAD value as an integrity-protected
Header Parameter value, but at the cost of the value being double
base64url encoded.)
JWE Ciphertext
Ciphertext value resulting from authenticated encryption of the
plaintext with Additional Authenticated Data.
JWE Authentication Tag
Authentication Tag value resulting from authenticated encryption
of the plaintext with Additional Authenticated Data.
JWE Protected Header
JSON object that contains the Header Parameters that are integrity
protected by the authenticated encryption operation. These
parameters apply to all recipients of the JWE. For the JWE
Compact Serialization, this comprises the entire JOSE Header. For
the JWE JSON Serialization, this is one component of the JOSE
Header.
JWE Shared Unprotected Header
JSON object that contains the Header Parameters that apply to all
recipients of the JWE that are not integrity protected. This can
only be present when using the JWE JSON Serialization.
JWE Per-Recipient Unprotected Header
JSON object that contains Header Parameters that apply to a single
recipient of the JWE. These Header Parameter values are not
integrity protected. This can only be present when using the JWE
JSON Serialization.
JWE Compact Serialization
A representation of the JWE as a compact, URL-safe string.
<span class="grey">Jones & Hildebrand Standards Track [Page 6]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-7" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
JWE JSON Serialization
A representation of the JWE as a JSON object. The JWE JSON
Serialization enables the same content to be encrypted to multiple
parties. This representation is neither optimized for compactness
nor URL safe.
Key Management Mode
A method of determining the Content Encryption Key value to use.
Each algorithm used for determining the CEK value uses a specific
Key Management Mode. Key Management Modes employed by this
specification are Key Encryption, Key Wrapping, Direct Key
Agreement, Key Agreement with Key Wrapping, and Direct Encryption.
Key Encryption
A Key Management Mode in which the CEK value is encrypted to the
intended recipient using an asymmetric encryption algorithm.
Key Wrapping
A Key Management Mode in which the CEK value is encrypted to the
intended recipient using a symmetric key wrapping algorithm.
Direct Key Agreement
A Key Management Mode in which a key agreement algorithm is used
to agree upon the CEK value.
Key Agreement with Key Wrapping
A Key Management Mode in which a key agreement algorithm is used
to agree upon a symmetric key used to encrypt the CEK value to the
intended recipient using a symmetric key wrapping algorithm.
Direct Encryption
A Key Management Mode in which the CEK value used is the secret
symmetric key value shared between the parties.
<span class="grey">Jones & Hildebrand Standards Track [Page 7]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-8" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
<span class="h2"><a class="selflink" id="section-3" href="#section-3">3</a>. JSON Web Encryption (JWE) Overview</span>
JWE represents encrypted content using JSON data structures and
base64url encoding. These JSON data structures MAY contain
whitespace and/or line breaks before or after any JSON values or
structural characters, in accordance with <a href="./rfc7159#section-2">Section 2 of RFC 7159</a>
[<a href="./rfc7159" title=""The JavaScript Object Notation (JSON) Data Interchange Format"">RFC7159</a>]. A JWE represents these logical values (each of which is
defined in <a href="#section-2">Section 2</a>):
o JOSE Header
o JWE Encrypted Key
o JWE Initialization Vector
o JWE AAD
o JWE Ciphertext
o JWE Authentication Tag
For a JWE, the JOSE Header members are the union of the members of
these values (each of which is defined in <a href="#section-2">Section 2</a>):
o JWE Protected Header
o JWE Shared Unprotected Header
o JWE Per-Recipient Unprotected Header
JWE utilizes authenticated encryption to ensure the confidentiality
and integrity of the plaintext and the integrity of the JWE Protected
Header and the JWE AAD.
This document defines two serializations for JWEs: a compact, URL-
safe serialization called the JWE Compact Serialization and a JSON
serialization called the JWE JSON Serialization. In both
serializations, the JWE Protected Header, JWE Encrypted Key, JWE
Initialization Vector, JWE Ciphertext, and JWE Authentication Tag are
base64url encoded, since JSON lacks a way to directly represent
arbitrary octet sequences. When present, the JWE AAD is also
base64url encoded.
<span class="h3"><a class="selflink" id="section-3.1" href="#section-3.1">3.1</a>. JWE Compact Serialization Overview</span>
In the JWE Compact Serialization, no JWE Shared Unprotected Header or
JWE Per-Recipient Unprotected Header are used. In this case, the
JOSE Header and the JWE Protected Header are the same.
<span class="grey">Jones & Hildebrand Standards Track [Page 8]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-9" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
In the JWE Compact Serialization, a JWE is represented as the
concatenation:
BASE64URL(UTF8(JWE Protected Header)) || '.' ||
BASE64URL(JWE Encrypted Key) || '.' ||
BASE64URL(JWE Initialization Vector) || '.' ||
BASE64URL(JWE Ciphertext) || '.' ||
BASE64URL(JWE Authentication Tag)
See <a href="#section-7.1">Section 7.1</a> for more information about the JWE Compact
Serialization.
<span class="h3"><a class="selflink" id="section-3.2" href="#section-3.2">3.2</a>. JWE JSON Serialization Overview</span>
In the JWE JSON Serialization, one or more of the JWE Protected
Header, JWE Shared Unprotected Header, and JWE Per-Recipient
Unprotected Header MUST be present. In this case, the members of the
JOSE Header are the union of the members of the JWE Protected Header,
JWE Shared Unprotected Header, and JWE Per-Recipient Unprotected
Header values that are present.
In the JWE JSON Serialization, a JWE is represented as a JSON object
containing some or all of these eight members:
"protected", with the value BASE64URL(UTF8(JWE Protected Header))
"unprotected", with the value JWE Shared Unprotected Header
"header", with the value JWE Per-Recipient Unprotected Header
"encrypted_key", with the value BASE64URL(JWE Encrypted Key)
"iv", with the value BASE64URL(JWE Initialization Vector)
"ciphertext", with the value BASE64URL(JWE Ciphertext)
"tag", with the value BASE64URL(JWE Authentication Tag)
"aad", with the value BASE64URL(JWE AAD)
The six base64url-encoded result strings and the two unprotected JSON
object values are represented as members within a JSON object. The
inclusion of some of these values is OPTIONAL. The JWE JSON
Serialization can also encrypt the plaintext to multiple recipients.
See <a href="#section-7.2">Section 7.2</a> for more information about the JWE JSON
Serialization.
<span class="grey">Jones & Hildebrand Standards Track [Page 9]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-10" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
<span class="h3"><a class="selflink" id="section-3.3" href="#section-3.3">3.3</a>. Example JWE</span>
This example encrypts the plaintext "The true sign of intelligence is
not knowledge but imagination." to the recipient.
The following example JWE Protected Header declares that:
o The Content Encryption Key is encrypted to the recipient using the
RSAES-OAEP [<a href="./rfc3447" title=""Public-Key Cryptography Standards (PKCS) #1: RSA Cryptography Specifications Version 2.1"">RFC3447</a>] algorithm to produce the JWE Encrypted Key.
o Authenticated encryption is performed on the plaintext using the
AES GCM [<a href="#ref-AES" title=""Advanced Encryption Standard (AES)"">AES</a>] [<a href="#ref-NIST.800-38D">NIST.800-38D</a>] algorithm with a 256-bit key to
produce the ciphertext and the Authentication Tag.
{"alg":"RSA-OAEP","enc":"A256GCM"}
Encoding this JWE Protected Header as BASE64URL(UTF8(JWE Protected
Header)) gives this value:
eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ
The remaining steps to finish creating this JWE are:
o Generate a random Content Encryption Key (CEK).
o Encrypt the CEK with the recipient's public key using the RSAES-
OAEP algorithm to produce the JWE Encrypted Key.
o Base64url-encode the JWE Encrypted Key.
o Generate a random JWE Initialization Vector.
o Base64url-encode the JWE Initialization Vector.
o Let the Additional Authenticated Data encryption parameter be
ASCII(BASE64URL(UTF8(JWE Protected Header))).
o Perform authenticated encryption on the plaintext with the AES GCM
algorithm using the CEK as the encryption key, the JWE
Initialization Vector, and the Additional Authenticated Data
value, requesting a 128-bit Authentication Tag output.
o Base64url-encode the ciphertext.
o Base64url-encode the Authentication Tag.
<span class="grey">Jones & Hildebrand Standards Track [Page 10]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-11" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
o Assemble the final representation: The Compact Serialization of
this result is the string BASE64URL(UTF8(JWE Protected Header)) ||
'.' || BASE64URL(JWE Encrypted Key) || '.' || BASE64URL(JWE
Initialization Vector) || '.' || BASE64URL(JWE Ciphertext) || '.'
|| BASE64URL(JWE Authentication Tag).
The final result in this example (with line breaks for display
purposes only) is:
eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ.
OKOawDo13gRp2ojaHV7LFpZcgV7T6DVZKTyKOMTYUmKoTCVJRgckCL9kiMT03JGe
ipsEdY3mx_etLbbWSrFr05kLzcSr4qKAq7YN7e9jwQRb23nfa6c9d-StnImGyFDb
Sv04uVuxIp5Zms1gNxKKK2Da14B8S4rzVRltdYwam_lDp5XnZAYpQdb76FdIKLaV
mqgfwX7XWRxv2322i-vDxRfqNzo_tETKzpVLzfiwQyeyPGLBIO56YJ7eObdv0je8
1860ppamavo35UgoRdbYaBcoh9QcfylQr66oc6vFWXRcZ_ZT2LawVCWTIy3brGPi
6UklfCpIMfIjf7iGdXKHzg.
48V1_ALb6US04U3b.
5eym8TW_c8SuK0ltJ3rpYIzOeDQz7TALvtu6UG9oMo4vpzs9tX_EFShS8iB7j6ji
SdiwkIr3ajwQzaBtQD_A.
XFBoMYUZodetZdvTiFvSkQ
See <a href="#appendix-A.1">Appendix A.1</a> for the complete details of computing this JWE. See
<a href="#appendix-A">Appendix A</a> for additional examples, including examples using the JWE
JSON Serialization in Sections A.4 and A.5.
<span class="h2"><a class="selflink" id="section-4" href="#section-4">4</a>. JOSE Header</span>
For a JWE, the members of the JSON object(s) representing the JOSE
Header describe the encryption applied to the plaintext and
optionally additional properties of the JWE. The Header Parameter
names within the JOSE Header MUST be unique, just as described in
Section 4 of [<a href="#ref-JWS" title=""JSON Web Signature (JWS)"">JWS</a>]. The rules about handling Header Parameters that
are not understood by the implementation are also the same. The
classes of Header Parameter names are likewise the same.
<span class="h3"><a class="selflink" id="section-4.1" href="#section-4.1">4.1</a>. Registered Header Parameter Names</span>
The following Header Parameter names for use in JWEs are registered
in the IANA "JSON Web Signature and Encryption Header Parameters"
registry established by [<a href="#ref-JWS" title=""JSON Web Signature (JWS)"">JWS</a>], with meanings as defined below.
As indicated by the common registry, JWSs and JWEs share a common
Header Parameter space; when a parameter is used by both
specifications, its usage must be compatible between the
specifications.
<span class="grey">Jones & Hildebrand Standards Track [Page 11]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-12" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
<span class="h4"><a class="selflink" id="section-4.1.1" href="#section-4.1.1">4.1.1</a>. "alg" (Algorithm) Header Parameter</span>
This parameter has the same meaning, syntax, and processing rules as
the "alg" Header Parameter defined in Section 4.1.1 of [<a href="#ref-JWS" title=""JSON Web Signature (JWS)"">JWS</a>], except
that the Header Parameter identifies the cryptographic algorithm used
to encrypt or determine the value of the CEK. The encrypted content
is not usable if the "alg" value does not represent a supported
algorithm, or if the recipient does not have a key that can be used
with that algorithm.
A list of defined "alg" values for this use can be found in the IANA
"JSON Web Signature and Encryption Algorithms" registry established
by [<a href="#ref-JWA" title=""JSON Web Algorithms (JWA)"">JWA</a>]; the initial contents of this registry are the values
defined in Section 4.1 of [<a href="#ref-JWA" title=""JSON Web Algorithms (JWA)"">JWA</a>].
<span class="h4"><a class="selflink" id="section-4.1.2" href="#section-4.1.2">4.1.2</a>. "enc" (Encryption Algorithm) Header Parameter</span>
The "enc" (encryption algorithm) Header Parameter identifies the
content encryption algorithm used to perform authenticated encryption
on the plaintext to produce the ciphertext and the Authentication
Tag. This algorithm MUST be an AEAD algorithm with a specified key
length. The encrypted content is not usable if the "enc" value does
not represent a supported algorithm. "enc" values should either be
registered in the IANA "JSON Web Signature and Encryption Algorithms"
registry established by [<a href="#ref-JWA" title=""JSON Web Algorithms (JWA)"">JWA</a>] or be a value that contains a
Collision-Resistant Name. The "enc" value is a case-sensitive ASCII
string containing a StringOrURI value. This Header Parameter MUST be
present and MUST be understood and processed by implementations.
A list of defined "enc" values for this use can be found in the IANA
"JSON Web Signature and Encryption Algorithms" registry established
by [<a href="#ref-JWA" title=""JSON Web Algorithms (JWA)"">JWA</a>]; the initial contents of this registry are the values
defined in Section 5.1 of [<a href="#ref-JWA" title=""JSON Web Algorithms (JWA)"">JWA</a>].
<span class="h4"><a class="selflink" id="section-4.1.3" href="#section-4.1.3">4.1.3</a>. "zip" (Compression Algorithm) Header Parameter</span>
The "zip" (compression algorithm) applied to the plaintext before
encryption, if any. The "zip" value defined by this specification
is:
o "DEF" - Compression with the DEFLATE [<a href="./rfc1951" title=""DEFLATE Compressed Data Format Specification version 1.3"">RFC1951</a>] algorithm
Other values MAY be used. Compression algorithm values can be
registered in the IANA "JSON Web Encryption Compression Algorithms"
registry established by [<a href="#ref-JWA" title=""JSON Web Algorithms (JWA)"">JWA</a>]. The "zip" value is a case-sensitive
string. If no "zip" parameter is present, no compression is applied
to the plaintext before encryption. When used, this Header Parameter
MUST be integrity protected; therefore, it MUST occur only within the
<span class="grey">Jones & Hildebrand Standards Track [Page 12]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-13" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
JWE Protected Header. Use of this Header Parameter is OPTIONAL.
This Header Parameter MUST be understood and processed by
implementations.
<span class="h4"><a class="selflink" id="section-4.1.4" href="#section-4.1.4">4.1.4</a>. "jku" (JWK Set URL) Header Parameter</span>
This parameter has the same meaning, syntax, and processing rules as
the "jku" Header Parameter defined in Section 4.1.2 of [<a href="#ref-JWS" title=""JSON Web Signature (JWS)"">JWS</a>], except
that the JWK Set resource contains the public key to which the JWE
was encrypted; this can be used to determine the private key needed
to decrypt the JWE.
<span class="h4"><a class="selflink" id="section-4.1.5" href="#section-4.1.5">4.1.5</a>. "jwk" (JSON Web Key) Header Parameter</span>
This parameter has the same meaning, syntax, and processing rules as
the "jwk" Header Parameter defined in Section 4.1.3 of [<a href="#ref-JWS" title=""JSON Web Signature (JWS)"">JWS</a>], except
that the key is the public key to which the JWE was encrypted; this
can be used to determine the private key needed to decrypt the JWE.
<span class="h4"><a class="selflink" id="section-4.1.6" href="#section-4.1.6">4.1.6</a>. "kid" (Key ID) Header Parameter</span>
This parameter has the same meaning, syntax, and processing rules as
the "kid" Header Parameter defined in Section 4.1.4 of [<a href="#ref-JWS" title=""JSON Web Signature (JWS)"">JWS</a>], except
that the key hint references the public key to which the JWE was
encrypted; this can be used to determine the private key needed to
decrypt the JWE. This parameter allows originators to explicitly
signal a change of key to JWE recipients.
<span class="h4"><a class="selflink" id="section-4.1.7" href="#section-4.1.7">4.1.7</a>. "x5u" (X.509 URL) Header Parameter</span>
This parameter has the same meaning, syntax, and processing rules as
the "x5u" Header Parameter defined in Section 4.1.5 of [<a href="#ref-JWS" title=""JSON Web Signature (JWS)"">JWS</a>], except
that the X.509 public key certificate or certificate chain [<a href="./rfc5280" title=""Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile"">RFC5280</a>]
contains the public key to which the JWE was encrypted; this can be
used to determine the private key needed to decrypt the JWE.
<span class="h4"><a class="selflink" id="section-4.1.8" href="#section-4.1.8">4.1.8</a>. "x5c" (X.509 Certificate Chain) Header Parameter</span>
This parameter has the same meaning, syntax, and processing rules as
the "x5c" Header Parameter defined in Section 4.1.6 of [<a href="#ref-JWS" title=""JSON Web Signature (JWS)"">JWS</a>], except
that the X.509 public key certificate or certificate chain [<a href="./rfc5280" title=""Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile"">RFC5280</a>]
contains the public key to which the JWE was encrypted; this can be
used to determine the private key needed to decrypt the JWE.
See <a href="#appendix-B">Appendix B</a> of [<a href="#ref-JWS" title=""JSON Web Signature (JWS)"">JWS</a>] for an example "x5c" value.
<span class="grey">Jones & Hildebrand Standards Track [Page 13]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-14" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
<span class="h4"><a class="selflink" id="section-4.1.9" href="#section-4.1.9">4.1.9</a>. "x5t" (X.509 Certificate SHA-1 Thumbprint) Header Parameter</span>
This parameter has the same meaning, syntax, and processing rules as
the "x5t" Header Parameter defined in Section 4.1.7 of [<a href="#ref-JWS" title=""JSON Web Signature (JWS)"">JWS</a>], except
that the certificate referenced by the thumbprint contains the public
key to which the JWE was encrypted; this can be used to determine the
private key needed to decrypt the JWE. Note that certificate
thumbprints are also sometimes known as certificate fingerprints.
<span class="h4"><a class="selflink" id="section-4.1.10" href="#section-4.1.10">4.1.10</a>. "x5t#S256" (X.509 Certificate SHA-256 Thumbprint) Header</span>
<span class="h4"> Parameter</span>
This parameter has the same meaning, syntax, and processing rules as
the "x5t#S256" Header Parameter defined in Section 4.1.8 of [<a href="#ref-JWS" title=""JSON Web Signature (JWS)"">JWS</a>],
except that the certificate referenced by the thumbprint contains the
public key to which the JWE was encrypted; this can be used to
determine the private key needed to decrypt the JWE. Note that
certificate thumbprints are also sometimes known as certificate
fingerprints.
<span class="h4"><a class="selflink" id="section-4.1.11" href="#section-4.1.11">4.1.11</a>. "typ" (Type) Header Parameter</span>
This parameter has the same meaning, syntax, and processing rules as
the "typ" Header Parameter defined in Section 4.1.9 of [<a href="#ref-JWS" title=""JSON Web Signature (JWS)"">JWS</a>], except
that the type is that of this complete JWE.
<span class="h4"><a class="selflink" id="section-4.1.12" href="#section-4.1.12">4.1.12</a>. "cty" (Content Type) Header Parameter</span>
This parameter has the same meaning, syntax, and processing rules as
the "cty" Header Parameter defined in Section 4.1.10 of [<a href="#ref-JWS" title=""JSON Web Signature (JWS)"">JWS</a>], except
that the type is that of the secured content (the plaintext).
<span class="h4"><a class="selflink" id="section-4.1.13" href="#section-4.1.13">4.1.13</a>. "crit" (Critical) Header Parameter</span>
This parameter has the same meaning, syntax, and processing rules as
the "crit" Header Parameter defined in Section 4.1.11 of [<a href="#ref-JWS" title=""JSON Web Signature (JWS)"">JWS</a>],
except that Header Parameters for a JWE are being referred to, rather
than Header Parameters for a JWS.
<span class="h3"><a class="selflink" id="section-4.2" href="#section-4.2">4.2</a>. Public Header Parameter Names</span>
Additional Header Parameter names can be defined by those using JWEs.
However, in order to prevent collisions, any new Header Parameter
name should either be registered in the IANA "JSON Web Signature and
Encryption Header Parameters" registry established by [<a href="#ref-JWS" title=""JSON Web Signature (JWS)"">JWS</a>] or be a
Public Name: a value that contains a Collision-Resistant Name. In
each case, the definer of the name or value needs to take reasonable
<span class="grey">Jones & Hildebrand Standards Track [Page 14]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-15" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
precautions to make sure they are in control of the part of the
namespace they use to define the Header Parameter name.
New Header Parameters should be introduced sparingly, as they can
result in non-interoperable JWEs.
<span class="h3"><a class="selflink" id="section-4.3" href="#section-4.3">4.3</a>. Private Header Parameter Names</span>
A producer and consumer of a JWE may agree to use Header Parameter
names that are Private Names: names that are not Registered Header
Parameter names (<a href="#section-4.1">Section 4.1</a>) or Public Header Parameter names
(<a href="#section-4.2">Section 4.2</a>). Unlike Public Header Parameter names, Private Header
Parameter names are subject to collision and should be used with
caution.
<span class="h2"><a class="selflink" id="section-5" href="#section-5">5</a>. Producing and Consuming JWEs</span>
<span class="h3"><a class="selflink" id="section-5.1" href="#section-5.1">5.1</a>. Message Encryption</span>
The message encryption process is as follows. The order of the steps
is not significant in cases where there are no dependencies between
the inputs and outputs of the steps.
1. Determine the Key Management Mode employed by the algorithm used
to determine the Content Encryption Key value. (This is the
algorithm recorded in the "alg" (algorithm) Header Parameter of
the resulting JWE.)
2. When Key Wrapping, Key Encryption, or Key Agreement with Key
Wrapping are employed, generate a random CEK value. See <a href="./rfc4086">RFC</a>
<a href="./rfc4086">4086</a> [<a href="./rfc4086" title=""Randomness Requirements for Security"">RFC4086</a>] for considerations on generating random values.
The CEK MUST have a length equal to that required for the
content encryption algorithm.
3. When Direct Key Agreement or Key Agreement with Key Wrapping are
employed, use the key agreement algorithm to compute the value
of the agreed upon key. When Direct Key Agreement is employed,
let the CEK be the agreed upon key. When Key Agreement with Key
Wrapping is employed, the agreed upon key will be used to wrap
the CEK.
4. When Key Wrapping, Key Encryption, or Key Agreement with Key
Wrapping are employed, encrypt the CEK to the recipient and let
the result be the JWE Encrypted Key.
5. When Direct Key Agreement or Direct Encryption are employed, let
the JWE Encrypted Key be the empty octet sequence.
<span class="grey">Jones & Hildebrand Standards Track [Page 15]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-16" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
6. When Direct Encryption is employed, let the CEK be the shared
symmetric key.
7. Compute the encoded key value BASE64URL(JWE Encrypted Key).
8. If the JWE JSON Serialization is being used, repeat this process
(steps 1-7) for each recipient.
9. Generate a random JWE Initialization Vector of the correct size
for the content encryption algorithm (if required for the
algorithm); otherwise, let the JWE Initialization Vector be the
empty octet sequence.
10. Compute the encoded Initialization Vector value BASE64URL(JWE
Initialization Vector).
11. If a "zip" parameter was included, compress the plaintext using
the specified compression algorithm and let M be the octet
sequence representing the compressed plaintext; otherwise, let M
be the octet sequence representing the plaintext.
12. Create the JSON object(s) containing the desired set of Header
Parameters, which together comprise the JOSE Header: one or more
of the JWE Protected Header, the JWE Shared Unprotected Header,
and the JWE Per-Recipient Unprotected Header.
13. Compute the Encoded Protected Header value BASE64URL(UTF8(JWE
Protected Header)). If the JWE Protected Header is not present
(which can only happen when using the JWE JSON Serialization and
no "protected" member is present), let this value be the empty
string.
14. Let the Additional Authenticated Data encryption parameter be
ASCII(Encoded Protected Header). However, if a JWE AAD value is
present (which can only be the case when using the JWE JSON
Serialization), instead let the Additional Authenticated Data
encryption parameter be ASCII(Encoded Protected Header || '.' ||
BASE64URL(JWE AAD)).
15. Encrypt M using the CEK, the JWE Initialization Vector, and the
Additional Authenticated Data value using the specified content
encryption algorithm to create the JWE Ciphertext value and the
JWE Authentication Tag (which is the Authentication Tag output
from the encryption operation).
16. Compute the encoded ciphertext value BASE64URL(JWE Ciphertext).
<span class="grey">Jones & Hildebrand Standards Track [Page 16]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-17" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
17. Compute the encoded Authentication Tag value BASE64URL(JWE
Authentication Tag).
18. If a JWE AAD value is present, compute the encoded AAD value
BASE64URL(JWE AAD).
19. Create the desired serialized output. The Compact Serialization
of this result is the string BASE64URL(UTF8(JWE Protected
Header)) || '.' || BASE64URL(JWE Encrypted Key) || '.' ||
BASE64URL(JWE Initialization Vector) || '.' || BASE64URL(JWE
Ciphertext) || '.' || BASE64URL(JWE Authentication Tag). The
JWE JSON Serialization is described in <a href="#section-7.2">Section 7.2</a>.
<span class="h3"><a class="selflink" id="section-5.2" href="#section-5.2">5.2</a>. Message Decryption</span>
The message decryption process is the reverse of the encryption
process. The order of the steps is not significant in cases where
there are no dependencies between the inputs and outputs of the
steps. If any of these steps fail, the encrypted content cannot be
validated.
When there are multiple recipients, it is an application decision
which of the recipients' encrypted content must successfully validate
for the JWE to be accepted. In some cases, encrypted content for all
recipients must successfully validate or the JWE will be considered
invalid. In other cases, only the encrypted content for a single
recipient needs to be successfully validated. However, in all cases,
the encrypted content for at least one recipient MUST successfully
validate or the JWE MUST be considered invalid.
1. Parse the JWE representation to extract the serialized values
for the components of the JWE. When using the JWE Compact
Serialization, these components are the base64url-encoded
representations of the JWE Protected Header, the JWE Encrypted
Key, the JWE Initialization Vector, the JWE Ciphertext, and the
JWE Authentication Tag, and when using the JWE JSON
Serialization, these components also include the base64url-
encoded representation of the JWE AAD and the unencoded JWE
Shared Unprotected Header and JWE Per-Recipient Unprotected
Header values. When using the JWE Compact Serialization, the
JWE Protected Header, the JWE Encrypted Key, the JWE
Initialization Vector, the JWE Ciphertext, and the JWE
Authentication Tag are represented as base64url-encoded values
in that order, with each value being separated from the next by
a single period ('.') character, resulting in exactly four
delimiting period characters being used. The JWE JSON
Serialization is described in <a href="#section-7.2">Section 7.2</a>.
<span class="grey">Jones & Hildebrand Standards Track [Page 17]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-18" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
2. Base64url decode the encoded representations of the JWE
Protected Header, the JWE Encrypted Key, the JWE Initialization
Vector, the JWE Ciphertext, the JWE Authentication Tag, and the
JWE AAD, following the restriction that no line breaks,
whitespace, or other additional characters have been used.
3. Verify that the octet sequence resulting from decoding the
encoded JWE Protected Header is a UTF-8-encoded representation
of a completely valid JSON object conforming to <a href="./rfc7159">RFC 7159</a>
[<a href="./rfc7159" title=""The JavaScript Object Notation (JSON) Data Interchange Format"">RFC7159</a>]; let the JWE Protected Header be this JSON object.
4. If using the JWE Compact Serialization, let the JOSE Header be
the JWE Protected Header. Otherwise, when using the JWE JSON
Serialization, let the JOSE Header be the union of the members
of the JWE Protected Header, the JWE Shared Unprotected Header
and the corresponding JWE Per-Recipient Unprotected Header, all
of which must be completely valid JSON objects. During this
step, verify that the resulting JOSE Header does not contain
duplicate Header Parameter names. When using the JWE JSON
Serialization, this restriction includes that the same Header
Parameter name also MUST NOT occur in distinct JSON object
values that together comprise the JOSE Header.
5. Verify that the implementation understands and can process all
fields that it is required to support, whether required by this
specification, by the algorithms being used, or by the "crit"
Header Parameter value, and that the values of those parameters
are also understood and supported.
6. Determine the Key Management Mode employed by the algorithm
specified by the "alg" (algorithm) Header Parameter.
7. Verify that the JWE uses a key known to the recipient.
8. When Direct Key Agreement or Key Agreement with Key Wrapping are
employed, use the key agreement algorithm to compute the value
of the agreed upon key. When Direct Key Agreement is employed,
let the CEK be the agreed upon key. When Key Agreement with Key
Wrapping is employed, the agreed upon key will be used to
decrypt the JWE Encrypted Key.
9. When Key Wrapping, Key Encryption, or Key Agreement with Key
Wrapping are employed, decrypt the JWE Encrypted Key to produce
the CEK. The CEK MUST have a length equal to that required for
the content encryption algorithm. Note that when there are
multiple recipients, each recipient will only be able to decrypt
JWE Encrypted Key values that were encrypted to a key in that
recipient's possession. It is therefore normal to only be able
<span class="grey">Jones & Hildebrand Standards Track [Page 18]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-19" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
to decrypt one of the per-recipient JWE Encrypted Key values to
obtain the CEK value. Also, see <a href="#section-11.5">Section 11.5</a> for security
considerations on mitigating timing attacks.
10. When Direct Key Agreement or Direct Encryption are employed,
verify that the JWE Encrypted Key value is an empty octet
sequence.
11. When Direct Encryption is employed, let the CEK be the shared
symmetric key.
12. Record whether the CEK could be successfully determined for this
recipient or not.
13. If the JWE JSON Serialization is being used, repeat this process
(steps 4-12) for each recipient contained in the representation.
14. Compute the Encoded Protected Header value BASE64URL(UTF8(JWE
Protected Header)). If the JWE Protected Header is not present
(which can only happen when using the JWE JSON Serialization and
no "protected" member is present), let this value be the empty
string.
15. Let the Additional Authenticated Data encryption parameter be
ASCII(Encoded Protected Header). However, if a JWE AAD value is
present (which can only be the case when using the JWE JSON
Serialization), instead let the Additional Authenticated Data
encryption parameter be ASCII(Encoded Protected Header || '.' ||
BASE64URL(JWE AAD)).
16. Decrypt the JWE Ciphertext using the CEK, the JWE Initialization
Vector, the Additional Authenticated Data value, and the JWE
Authentication Tag (which is the Authentication Tag input to the
calculation) using the specified content encryption algorithm,
returning the decrypted plaintext and validating the JWE
Authentication Tag in the manner specified for the algorithm,
rejecting the input without emitting any decrypted output if the
JWE Authentication Tag is incorrect.
17. If a "zip" parameter was included, uncompress the decrypted
plaintext using the specified compression algorithm.
18. If there was no recipient for which all of the decryption steps
succeeded, then the JWE MUST be considered invalid. Otherwise,
output the plaintext. In the JWE JSON Serialization case, also
return a result to the application indicating for which of the
recipients the decryption succeeded and failed.
<span class="grey">Jones & Hildebrand Standards Track [Page 19]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-20" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
Finally, note that it is an application decision which algorithms may
be used in a given context. Even if a JWE can be successfully
decrypted, unless the algorithms used in the JWE are acceptable to
the application, it SHOULD consider the JWE to be invalid.
<span class="h3"><a class="selflink" id="section-5.3" href="#section-5.3">5.3</a>. String Comparison Rules</span>
The string comparison rules for this specification are the same as
those defined in Section 5.3 of [<a href="#ref-JWS" title=""JSON Web Signature (JWS)"">JWS</a>].
<span class="h2"><a class="selflink" id="section-6" href="#section-6">6</a>. Key Identification</span>
The key identification methods for this specification are the same as
those defined in Section 6 of [<a href="#ref-JWS" title=""JSON Web Signature (JWS)"">JWS</a>], except that the key being
identified is the public key to which the JWE was encrypted.
<span class="h2"><a class="selflink" id="section-7" href="#section-7">7</a>. Serializations</span>
JWEs use one of two serializations: the JWE Compact Serialization or
the JWE JSON Serialization. Applications using this specification
need to specify what serialization and serialization features are
used for that application. For instance, applications might specify
that only the JWE JSON Serialization is used, that only JWE JSON
Serialization support for a single recipient is used, or that support
for multiple recipients is used. JWE implementations only need to
implement the features needed for the applications they are designed
to support.
<span class="h3"><a class="selflink" id="section-7.1" href="#section-7.1">7.1</a>. JWE Compact Serialization</span>
The JWE Compact Serialization represents encrypted content as a
compact, URL-safe string. This string is:
BASE64URL(UTF8(JWE Protected Header)) || '.' ||
BASE64URL(JWE Encrypted Key) || '.' ||
BASE64URL(JWE Initialization Vector) || '.' ||
BASE64URL(JWE Ciphertext) || '.' ||
BASE64URL(JWE Authentication Tag)
Only one recipient is supported by the JWE Compact Serialization and
it provides no syntax to represent JWE Shared Unprotected Header, JWE
Per-Recipient Unprotected Header, or JWE AAD values.
<span class="h3"><a class="selflink" id="section-7.2" href="#section-7.2">7.2</a>. JWE JSON Serialization</span>
The JWE JSON Serialization represents encrypted content as a JSON
object. This representation is neither optimized for compactness nor
URL safe.
<span class="grey">Jones & Hildebrand Standards Track [Page 20]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-21" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
Two closely related syntaxes are defined for the JWE JSON
Serialization: a fully general syntax, with which content can be
encrypted to more than one recipient, and a flattened syntax, which
is optimized for the single-recipient case.
<span class="h4"><a class="selflink" id="section-7.2.1" href="#section-7.2.1">7.2.1</a>. General JWE JSON Serialization Syntax</span>
The following members are defined for use in top-level JSON objects
used for the fully general JWE JSON Serialization syntax:
protected
The "protected" member MUST be present and contain the value
BASE64URL(UTF8(JWE Protected Header)) when the JWE Protected
Header value is non-empty; otherwise, it MUST be absent. These
Header Parameter values are integrity protected.
unprotected
The "unprotected" member MUST be present and contain the value JWE
Shared Unprotected Header when the JWE Shared Unprotected Header
value is non-empty; otherwise, it MUST be absent. This value is
represented as an unencoded JSON object, rather than as a string.
These Header Parameter values are not integrity protected.
iv
The "iv" member MUST be present and contain the value
BASE64URL(JWE Initialization Vector) when the JWE Initialization
Vector value is non-empty; otherwise, it MUST be absent.
aad
The "aad" member MUST be present and contain the value
BASE64URL(JWE AAD)) when the JWE AAD value is non-empty;
otherwise, it MUST be absent. A JWE AAD value can be included to
supply a base64url-encoded value to be integrity protected but not
encrypted.
ciphertext
The "ciphertext" member MUST be present and contain the value
BASE64URL(JWE Ciphertext).
tag
The "tag" member MUST be present and contain the value
BASE64URL(JWE Authentication Tag) when the JWE Authentication Tag
value is non-empty; otherwise, it MUST be absent.
recipients
The "recipients" member value MUST be an array of JSON objects.
Each object contains information specific to a single recipient.
This member MUST be present with exactly one array element per
<span class="grey">Jones & Hildebrand Standards Track [Page 21]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-22" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
recipient, even if some or all of the array element values are the
empty JSON object "{}" (which can happen when all Header Parameter
values are shared between all recipients and when no encrypted key
is used, such as when doing Direct Encryption).
The following members are defined for use in the JSON objects that
are elements of the "recipients" array:
header
The "header" member MUST be present and contain the value JWE Per-
Recipient Unprotected Header when the JWE Per-Recipient
Unprotected Header value is non-empty; otherwise, it MUST be
absent. This value is represented as an unencoded JSON object,
rather than as a string. These Header Parameter values are not
integrity protected.
encrypted_key
The "encrypted_key" member MUST be present and contain the value
BASE64URL(JWE Encrypted Key) when the JWE Encrypted Key value is
non-empty; otherwise, it MUST be absent.
At least one of the "header", "protected", and "unprotected" members
MUST be present so that "alg" and "enc" Header Parameter values are
conveyed for each recipient computation.
Additional members can be present in both the JSON objects defined
above; if not understood by implementations encountering them, they
MUST be ignored.
Some Header Parameters, including the "alg" parameter, can be shared
among all recipient computations. Header Parameters in the JWE
Protected Header and JWE Shared Unprotected Header values are shared
among all recipients.
The Header Parameter values used when creating or validating per-
recipient ciphertext and Authentication Tag values are the union of
the three sets of Header Parameter values that may be present: (1)
the JWE Protected Header represented in the "protected" member, (2)
the JWE Shared Unprotected Header represented in the "unprotected"
member, and (3) the JWE Per-Recipient Unprotected Header represented
in the "header" member of the recipient's array element. The union
of these sets of Header Parameters comprises the JOSE Header. The
Header Parameter names in the three locations MUST be disjoint.
Each JWE Encrypted Key value is computed using the parameters of the
corresponding JOSE Header value in the same manner as for the JWE
Compact Serialization. This has the desirable property that each JWE
Encrypted Key value in the "recipients" array is identical to the
<span class="grey">Jones & Hildebrand Standards Track [Page 22]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-23" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
value that would have been computed for the same parameter in the JWE
Compact Serialization. Likewise, the JWE Ciphertext and JWE
Authentication Tag values match those produced for the JWE Compact
Serialization, provided that the JWE Protected Header value (which
represents the integrity-protected Header Parameter values) matches
that used in the JWE Compact Serialization.
All recipients use the same JWE Protected Header, JWE Initialization
Vector, JWE Ciphertext, and JWE Authentication Tag values, when
present, resulting in potentially significant space savings if the
message is large. Therefore, all Header Parameters that specify the
treatment of the plaintext value MUST be the same for all recipients.
This primarily means that the "enc" (encryption algorithm) Header
Parameter value in the JOSE Header for each recipient and any
parameters of that algorithm MUST be the same.
In summary, the syntax of a JWE using the general JWE JSON
Serialization is as follows:
{
"protected":"<integrity-protected shared header contents>",
"unprotected":<non-integrity-protected shared header contents>,
"recipients":[
{"header":<per-recipient unprotected header 1 contents>,
"encrypted_key":"<encrypted key 1 contents>"},
...
{"header":<per-recipient unprotected header N contents>,
"encrypted_key":"<encrypted key N contents>"}],
"aad":"<additional authenticated data contents>",
"iv":"<initialization vector contents>",
"ciphertext":"<ciphertext contents>",
"tag":"<authentication tag contents>"
}
See <a href="#appendix-A.4">Appendix A.4</a> for an example JWE using the general JWE JSON
Serialization syntax.
<span class="h4"><a class="selflink" id="section-7.2.2" href="#section-7.2.2">7.2.2</a>. Flattened JWE JSON Serialization Syntax</span>
The flattened JWE JSON Serialization syntax is based upon the general
syntax, but flattens it, optimizing it for the single-recipient case.
It flattens it by removing the "recipients" member and instead
placing those members defined for use in the "recipients" array (the
"header" and "encrypted_key" members) in the top-level JSON object
(at the same level as the "ciphertext" member).
<span class="grey">Jones & Hildebrand Standards Track [Page 23]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-24" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
The "recipients" member MUST NOT be present when using this syntax.
Other than this syntax difference, JWE JSON Serialization objects
using the flattened syntax are processed identically to those using
the general syntax.
In summary, the syntax of a JWE using the flattened JWE JSON
Serialization is as follows:
{
"protected":"<integrity-protected header contents>",
"unprotected":<non-integrity-protected header contents>,
"header":<more non-integrity-protected header contents>,
"encrypted_key":"<encrypted key contents>",
"aad":"<additional authenticated data contents>",
"iv":"<initialization vector contents>",
"ciphertext":"<ciphertext contents>",
"tag":"<authentication tag contents>"
}
Note that when using the flattened syntax, just as when using the
general syntax, any unprotected Header Parameter values can reside in
either the "unprotected" member or the "header" member, or in both.
See <a href="#appendix-A.5">Appendix A.5</a> for an example JWE using the flattened JWE JSON
Serialization syntax.
<span class="h2"><a class="selflink" id="section-8" href="#section-8">8</a>. TLS Requirements</span>
The Transport Layer Security (TLS) requirements for this
specification are the same as those defined in Section 8 of [<a href="#ref-JWS" title=""JSON Web Signature (JWS)"">JWS</a>].
<span class="h2"><a class="selflink" id="section-9" href="#section-9">9</a>. Distinguishing between JWS and JWE Objects</span>
There are several ways of distinguishing whether an object is a JWS
or JWE. All these methods will yield the same result for all legal
input values; they may yield different results for malformed inputs.
o If the object is using the JWS Compact Serialization or the JWE
Compact Serialization, the number of base64url-encoded segments
separated by period ('.') characters differs for JWSs and JWEs.
JWSs have three segments separated by two period ('.') characters.
JWEs have five segments separated by four period ('.') characters.
o If the object is using the JWS JSON Serialization or the JWE JSON
Serialization, the members used will be different. JWSs have a
"payload" member and JWEs do not. JWEs have a "ciphertext" member
and JWSs do not.
<span class="grey">Jones & Hildebrand Standards Track [Page 24]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-25" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
o The JOSE Header for a JWS can be distinguished from the JOSE
Header for a JWE by examining the "alg" (algorithm) Header
Parameter value. If the value represents a digital signature or
MAC algorithm, or is the value "none", it is for a JWS; if it
represents a Key Encryption, Key Wrapping, Direct Key Agreement,
Key Agreement with Key Wrapping, or Direct Encryption algorithm,
it is for a JWE. (Extracting the "alg" value to examine is
straightforward when using the JWS Compact Serialization or the
JWE Compact Serialization and may be more difficult when using the
JWS JSON Serialization or the JWE JSON Serialization.)
o The JOSE Header for a JWS can also be distinguished from the JOSE
Header for a JWE by determining whether an "enc" (encryption
algorithm) member exists. If the "enc" member exists, it is a
JWE; otherwise, it is a JWS.
<span class="h2"><a class="selflink" id="section-10" href="#section-10">10</a>. IANA Considerations</span>
<span class="h3"><a class="selflink" id="section-10.1" href="#section-10.1">10.1</a>. JSON Web Signature and Encryption Header Parameters Registration</span>
This section registers the Header Parameter names defined in
<a href="#section-4.1">Section 4.1</a> in the IANA "JSON Web Signature and Encryption Header
Parameters" registry established by [<a href="#ref-JWS" title=""JSON Web Signature (JWS)"">JWS</a>].
<span class="h4"><a class="selflink" id="section-10.1.1" href="#section-10.1.1">10.1.1</a>. Registry Contents</span>
o Header Parameter Name: "alg"
o Header Parameter Description: Algorithm
o Header Parameter Usage Location(s): JWE
o Change Controller: IESG
o Specification Document(s): <a href="./rfc7516#section-4.1.1">Section 4.1.1 of RFC 7516</a>
o Header Parameter Name: "enc"
o Header Parameter Description: Encryption Algorithm
o Header Parameter Usage Location(s): JWE
o Change Controller: IESG
o Specification Document(s): <a href="./rfc7516#section-4.1.2">Section 4.1.2 of RFC 7516</a>
o Header Parameter Name: "zip"
o Header Parameter Description: Compression Algorithm
o Header Parameter Usage Location(s): JWE
o Change Controller: IESG
o Specification Document(s): <a href="./rfc7516#section-4.1.3">Section 4.1.3 of RFC 7516</a>
<span class="grey">Jones & Hildebrand Standards Track [Page 25]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-26" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
o Header Parameter Name: "jku"
o Header Parameter Description: JWK Set URL
o Header Parameter Usage Location(s): JWE
o Change Controller: IESG
o Specification Document(s): <a href="./rfc7516#section-4.1.4">Section 4.1.4 of RFC 7516</a>
o Header Parameter Name: "jwk"
o Header Parameter Description: JSON Web Key
o Header Parameter Usage Location(s): JWE
o Change Controller: IESG
o Specification Document(s): <a href="./rfc7516#section-4.1.5">Section 4.1.5 of RFC 7516</a>
o Header Parameter Name: "kid"
o Header Parameter Description: Key ID
o Header Parameter Usage Location(s): JWE
o Change Controller: IESG
o Specification Document(s): <a href="./rfc7516#section-4.1.6">Section 4.1.6 of RFC 7516</a>
o Header Parameter Name: "x5u"
o Header Parameter Description: X.509 URL
o Header Parameter Usage Location(s): JWE
o Change Controller: IESG
o Specification Document(s): <a href="./rfc7516#section-4.1.7">Section 4.1.7 of RFC 7516</a>
o Header Parameter Name: "x5c"
o Header Parameter Description: X.509 Certificate Chain
o Header Parameter Usage Location(s): JWE
o Change Controller: IESG
o Specification Document(s): <a href="./rfc7516#section-4.1.8">Section 4.1.8 of RFC 7516</a>
o Header Parameter Name: "x5t"
o Header Parameter Description: X.509 Certificate SHA-1 Thumbprint
o Header Parameter Usage Location(s): JWE
o Change Controller: IESG
o Specification Document(s): <a href="./rfc7516#section-4.1.9">Section 4.1.9 of RFC 7516</a>
o Header Parameter Name: "x5t#S256"
o Header Parameter Description: X.509 Certificate SHA-256 Thumbprint
o Header Parameter Usage Location(s): JWE
o Change Controller: IESG
o Specification Document(s): <a href="./rfc7516#section-4.1.10">Section 4.1.10 of RFC 7516</a>
o Header Parameter Name: "typ"
o Header Parameter Description: Type
o Header Parameter Usage Location(s): JWE
o Change Controller: IESG
o Specification Document(s): <a href="./rfc7516#section-4.1.11">Section 4.1.11 of RFC 7516</a>
<span class="grey">Jones & Hildebrand Standards Track [Page 26]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-27" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
o Header Parameter Name: "cty"
o Header Parameter Description: Content Type
o Header Parameter Usage Location(s): JWE
o Change Controller: IESG
o Specification Document(s): <a href="./rfc7516#section-4.1.12">Section 4.1.12 of RFC 7516</a>
o Header Parameter Name: "crit"
o Header Parameter Description: Critical
o Header Parameter Usage Location(s): JWE
o Change Controller: IESG
o Specification Document(s): <a href="./rfc7516#section-4.1.13">Section 4.1.13 of RFC 7516</a>
<span class="h2"><a class="selflink" id="section-11" href="#section-11">11</a>. Security Considerations</span>
All of the security issues that are pertinent to any cryptographic
application must be addressed by JWS/JWE/JWK agents. Among these
issues are protecting the user's asymmetric private and symmetric
secret keys and employing countermeasures to various attacks.
All the security considerations in the JWS specification also apply
to this specification. Likewise, all the security considerations in
XML Encryption 1.1 [<a href="#ref-W3C.REC-xmlenc-core1-20130411">W3C.REC-xmlenc-core1-20130411</a>] also apply, other
than those that are XML specific.
<span class="h3"><a class="selflink" id="section-11.1" href="#section-11.1">11.1</a>. Key Entropy and Random Values</span>
See Section 10.1 of [<a href="#ref-JWS" title=""JSON Web Signature (JWS)"">JWS</a>] for security considerations on key entropy
and random values. In addition to the uses of random values listed
there, note that random values are also used for Content Encryption
Keys (CEKs) and Initialization Vectors (IVs) when performing
encryption.
<span class="h3"><a class="selflink" id="section-11.2" href="#section-11.2">11.2</a>. Key Protection</span>
See Section 10.2 of [<a href="#ref-JWS" title=""JSON Web Signature (JWS)"">JWS</a>] for security considerations on key
protection. In addition to the keys listed there that must be
protected, implementations performing encryption must protect the key
encryption key and the Content Encryption Key. Compromise of the key
encryption key may result in the disclosure of all contents protected
with that key. Similarly, compromise of the Content Encryption Key
may result in disclosure of the associated encrypted content.
<span class="grey">Jones & Hildebrand Standards Track [Page 27]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-28" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
<span class="h3"><a class="selflink" id="section-11.3" href="#section-11.3">11.3</a>. Using Matching Algorithm Strengths</span>
Algorithms of matching strengths should be used together whenever
possible. For instance, when AES Key Wrap is used with a given key
size, using the same key size is recommended when AES GCM is also
used. If the key encryption and content encryption algorithms are
different, the effective security is determined by the weaker of the
two algorithms.
Also, see <a href="./rfc3766">RFC 3766</a> [<a href="./rfc3766" title=""Determining Strengths For Public Keys Used For Exchanging Symmetric Keys"">RFC3766</a>] for information on determining strengths
for public keys used for exchanging symmetric keys.
<span class="h3"><a class="selflink" id="section-11.4" href="#section-11.4">11.4</a>. Adaptive Chosen-Ciphertext Attacks</span>
When decrypting, particular care must be taken not to allow the JWE
recipient to be used as an oracle for decrypting messages. <a href="./rfc3218">RFC 3218</a>
[<a href="./rfc3218" title=""Preventing the Million Message Attack on Cryptographic Message Syntax"">RFC3218</a>] should be consulted for specific countermeasures to attacks
on RSAES-PKCS1-v1_5. An attacker might modify the contents of the
"alg" Header Parameter from "RSA-OAEP" to "RSA1_5" in order to
generate a formatting error that can be detected and used to recover
the CEK even if RSAES-OAEP was used to encrypt the CEK. It is
therefore particularly important to report all formatting errors to
the CEK, Additional Authenticated Data, or ciphertext as a single
error when the encrypted content is rejected.
Additionally, this type of attack can be prevented by restricting the
use of a key to a limited set of algorithms -- usually one. This
means, for instance, that if the key is marked as being for
"RSA-OAEP" only, any attempt to decrypt a message using the "RSA1_5"
algorithm with that key should fail immediately due to invalid use of
the key.
<span class="h3"><a class="selflink" id="section-11.5" href="#section-11.5">11.5</a>. Timing Attacks</span>
To mitigate the attacks described in <a href="./rfc3218">RFC 3218</a> [<a href="./rfc3218" title=""Preventing the Million Message Attack on Cryptographic Message Syntax"">RFC3218</a>], the
recipient MUST NOT distinguish between format, padding, and length
errors of encrypted keys. It is strongly recommended, in the event
of receiving an improperly formatted key, that the recipient
substitute a randomly generated CEK and proceed to the next step, to
mitigate timing attacks.
<span class="grey">Jones & Hildebrand Standards Track [Page 28]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-29" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
<span class="h2"><a class="selflink" id="section-12" href="#section-12">12</a>. References</span>
<span class="h3"><a class="selflink" id="section-12.1" href="#section-12.1">12.1</a>. Normative References</span>
[<a id="ref-JWA">JWA</a>] Jones, M., "JSON Web Algorithms (JWA)", <a href="./rfc7518">RFC 7518</a>,
DOI 10.17487/RFC7518, May 2015,
<<a href="http://www.rfc-editor.org/info/rfc7518">http://www.rfc-editor.org/info/rfc7518</a>>.
[<a id="ref-JWK">JWK</a>] Jones, M., "JSON Web Key (JWK)", <a href="./rfc7517">RFC 7517</a>,
DOI 10.17487/RFC7517, May 2015,
<<a href="http://www.rfc-editor.org/info/rfc7517">http://www.rfc-editor.org/info/rfc7517</a>>.
[<a id="ref-JWS">JWS</a>] Jones, M., Bradley, J., and N. Sakimura, "JSON Web
Signature (JWS)", <a href="./rfc7515">RFC 7515</a>, DOI 10.17487/RFC7515, May
2015, <<a href="http://www.rfc-editor.org/info/rfc7515">http://www.rfc-editor.org/info/rfc7515</a>>.
[<a id="ref-RFC1951">RFC1951</a>] Deutsch, P., "DEFLATE Compressed Data Format Specification
version 1.3", <a href="./rfc1951">RFC 1951</a>, DOI 10.17487/RFC1951, May 1996,
<<a href="http://www.rfc-editor.org/info/rfc1951">http://www.rfc-editor.org/info/rfc1951</a>>.
[<a id="ref-RFC20">RFC20</a>] Cerf, V., "ASCII format for Network Interchange", STD 80,
<a href="./rfc20">RFC 20</a>, DOI 10.17487/RFC0020, October 1969,
<<a href="http://www.rfc-editor.org/info/rfc20">http://www.rfc-editor.org/info/rfc20</a>>.
[<a id="ref-RFC2119">RFC2119</a>] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", <a href="https://www.rfc-editor.org/bcp/bcp14">BCP 14</a>, <a href="./rfc2119">RFC 2119</a>,
DOI 10.17487/RFC2119, March 1997,
<<a href="http://www.rfc-editor.org/info/rfc2119">http://www.rfc-editor.org/info/rfc2119</a>>.
[<a id="ref-RFC3629">RFC3629</a>] Yergeau, F., "UTF-8, a transformation format of ISO
10646", STD 63, <a href="./rfc3629">RFC 3629</a>, DOI 10.17487/RFC3629, November
2003, <<a href="http://www.rfc-editor.org/info/rfc3629">http://www.rfc-editor.org/info/rfc3629</a>>.
[<a id="ref-RFC4949">RFC4949</a>] Shirey, R., "Internet Security Glossary, Version 2",
FYI 36, <a href="./rfc4949">RFC 4949</a>, DOI 10.17487/RFC4949, August 2007,
<<a href="http://www.rfc-editor.org/info/rfc4949">http://www.rfc-editor.org/info/rfc4949</a>>.
[<a id="ref-RFC5280">RFC5280</a>] Cooper, D., Santesson, S., Farrell, S., Boeyen, S.,
Housley, R., and W. Polk, "Internet X.509 Public Key
Infrastructure Certificate and Certificate Revocation List
(CRL) Profile", <a href="./rfc5280">RFC 5280</a>, DOI 10.17487/RFC5280, May 2008,
<<a href="http://www.rfc-editor.org/info/rfc5280">http://www.rfc-editor.org/info/rfc5280</a>>.
[<a id="ref-RFC7159">RFC7159</a>] Bray, T., Ed., "The JavaScript Object Notation (JSON) Data
Interchange Format", <a href="./rfc7159">RFC 7159</a>, DOI 10.17487/RFC7159, March
2014, <<a href="http://www.rfc-editor.org/info/rfc7159">http://www.rfc-editor.org/info/rfc7159</a>>.
<span class="grey">Jones & Hildebrand Standards Track [Page 29]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-30" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
[<a id="ref-UNICODE">UNICODE</a>] The Unicode Consortium, "The Unicode Standard",
<<a href="http://www.unicode.org/versions/latest/">http://www.unicode.org/versions/latest/</a>>.
<span class="h3"><a class="selflink" id="section-12.2" href="#section-12.2">12.2</a>. Informative References</span>
[<a id="ref-AES">AES</a>] National Institute of Standards and Technology (NIST),
"Advanced Encryption Standard (AES)", FIPS PUB 197,
November 2001, <<a href="http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf">http://csrc.nist.gov/publications/</a>
<a href="http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf">fips/fips197/fips-197.pdf</a>>.
[<a id="ref-JSE">JSE</a>] Bradley, J. and N. Sakimura (editor), "JSON Simple
Encryption", September 2010,
<<a href="http://jsonenc.info/enc/1.0/">http://jsonenc.info/enc/1.0/</a>>.
[<a id="ref-JSMS">JSMS</a>] Rescorla, E. and J. Hildebrand, "JavaScript Message
Security Format", Work in Progress,
<a href="./draft-rescorla-jsms-00">draft-rescorla-jsms-00</a>, March 2011.
[<a id="ref-NIST.800-38D">NIST.800-38D</a>]
National Institute of Standards and Technology (NIST),
"Recommendation for Block Cipher Modes of Operation:
Galois/Counter Mode (GCM) and GMAC", NIST PUB 800-38D,
November 2007, <<a href="http://csrc.nist.gov/publications/nistpubs/800-38D/SP-800-38D.pdf">http://csrc.nist.gov/publications/</a>
<a href="http://csrc.nist.gov/publications/nistpubs/800-38D/SP-800-38D.pdf">nistpubs/800-38D/SP-800-38D.pdf</a>>.
[<a id="ref-RFC3218">RFC3218</a>] Rescorla, E., "Preventing the Million Message Attack on
Cryptographic Message Syntax", <a href="./rfc3218">RFC 3218</a>,
DOI 10.17487/RFC3218, January 2002,
<<a href="http://www.rfc-editor.org/info/rfc3218">http://www.rfc-editor.org/info/rfc3218</a>>.
[<a id="ref-RFC3447">RFC3447</a>] Jonsson, J. and B. Kaliski, "Public-Key Cryptography
Standards (PKCS) #1: RSA Cryptography Specifications
Version 2.1", <a href="./rfc3447">RFC 3447</a>, DOI 10.17487/RFC3447, February
2003, <<a href="http://www.rfc-editor.org/info/rfc3447">http://www.rfc-editor.org/info/rfc3447</a>>.
[<a id="ref-RFC3766">RFC3766</a>] Orman, H. and P. Hoffman, "Determining Strengths For
Public Keys Used For Exchanging Symmetric Keys", <a href="https://www.rfc-editor.org/bcp/bcp86">BCP 86</a>,
<a href="./rfc3766">RFC 3766</a>, DOI 10.17487/RFC3766, April 2004,
<<a href="http://www.rfc-editor.org/info/rfc3766">http://www.rfc-editor.org/info/rfc3766</a>>.
[<a id="ref-RFC4086">RFC4086</a>] Eastlake 3rd, D., Schiller, J., and S. Crocker,
"Randomness Requirements for Security", <a href="https://www.rfc-editor.org/bcp/bcp106">BCP 106</a>, <a href="./rfc4086">RFC 4086</a>,
DOI 10.17487/RFC4086, June 2005,
<<a href="http://www.rfc-editor.org/info/rfc4086">http://www.rfc-editor.org/info/rfc4086</a>>.
<span class="grey">Jones & Hildebrand Standards Track [Page 30]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-31" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
[<a id="ref-RFC5652">RFC5652</a>] Housley, R., "Cryptographic Message Syntax (CMS)", STD 70,
<a href="./rfc5652">RFC 5652</a>, DOI 10.17487/RFC5652, September 2009,
<<a href="http://www.rfc-editor.org/info/rfc5652">http://www.rfc-editor.org/info/rfc5652</a>>.
[<a id="ref-W3C.REC-xmlenc-core1-20130411">W3C.REC-xmlenc-core1-20130411</a>]
Eastlake, D., Reagle, J., Hirsch, F., and T. Roessler,
"XML Encryption Syntax and Processing Version 1.1", World
Wide Web Consortium Recommendation
REC-xmlenc-core1-20130411, April 2013,
<<a href="http://www.w3.org/TR/2013/REC-xmlenc-core1-20130411/">http://www.w3.org/TR/2013/REC-xmlenc-core1-20130411/</a>>.
<span class="grey">Jones & Hildebrand Standards Track [Page 31]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-32" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
<span class="h2"><a class="selflink" id="appendix-A" href="#appendix-A">Appendix A</a>. JWE Examples</span>
This section provides examples of JWE computations.
<span class="h3"><a class="selflink" id="appendix-A.1" href="#appendix-A.1">A.1</a>. Example JWE using RSAES-OAEP and AES GCM</span>
This example encrypts the plaintext "The true sign of intelligence is
not knowledge but imagination." to the recipient using RSAES-OAEP for
key encryption and AES GCM for content encryption. The
representation of this plaintext (using JSON array notation) is:
[84, 104, 101, 32, 116, 114, 117, 101, 32, 115, 105, 103, 110, 32,
111, 102, 32, 105, 110, 116, 101, 108, 108, 105, 103, 101, 110, 99,
101, 32, 105, 115, 32, 110, 111, 116, 32, 107, 110, 111, 119, 108,
101, 100, 103, 101, 32, 98, 117, 116, 32, 105, 109, 97, 103, 105,
110, 97, 116, 105, 111, 110, 46]
<span class="h4"><a class="selflink" id="appendix-A.1.1" href="#appendix-A.1.1">A.1.1</a>. JOSE Header</span>
The following example JWE Protected Header declares that:
o The Content Encryption Key is encrypted to the recipient using the
RSAES-OAEP algorithm to produce the JWE Encrypted Key.
o Authenticated encryption is performed on the plaintext using the
AES GCM algorithm with a 256-bit key to produce the ciphertext and
the Authentication Tag.
{"alg":"RSA-OAEP","enc":"A256GCM"}
Encoding this JWE Protected Header as BASE64URL(UTF8(JWE Protected
Header)) gives this value:
eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ
<span class="h4"><a class="selflink" id="appendix-A.1.2" href="#appendix-A.1.2">A.1.2</a>. Content Encryption Key (CEK)</span>
Generate a 256-bit random CEK. In this example, the value (using
JSON array notation) is:
[177, 161, 244, 128, 84, 143, 225, 115, 63, 180, 3, 255, 107, 154,
212, 246, 138, 7, 110, 91, 112, 46, 34, 105, 47, 130, 203, 46, 122,
234, 64, 252]
<span class="grey">Jones & Hildebrand Standards Track [Page 32]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-33" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
<span class="h4"><a class="selflink" id="appendix-A.1.3" href="#appendix-A.1.3">A.1.3</a>. Key Encryption</span>
Encrypt the CEK with the recipient's public key using the RSAES-OAEP
algorithm to produce the JWE Encrypted Key. This example uses the
RSA key represented in JSON Web Key [<a href="#ref-JWK" title=""JSON Web Key (JWK)"">JWK</a>] format below (with line
breaks within values for display purposes only):
{"kty":"RSA",
"n":"oahUIoWw0K0usKNuOR6H4wkf4oBUXHTxRvgb48E-BVvxkeDNjbC4he8rUW
cJoZmds2h7M70imEVhRU5djINXtqllXI4DFqcI1DgjT9LewND8MW2Krf3S
psk_ZkoFnilakGygTwpZ3uesH-PFABNIUYpOiN15dsQRkgr0vEhxN92i2a
sbOenSZeyaxziK72UwxrrKoExv6kc5twXTq4h-QChLOln0_mtUZwfsRaMS
tPs6mS6XrgxnxbWhojf663tuEQueGC-FCMfra36C9knDFGzKsNa7LZK2dj
YgyD3JR_MB_4NUJW_TqOQtwHYbxevoJArm-L5StowjzGy-_bq6Gw",
"e":"AQAB",
"d":"kLdtIj6GbDks_ApCSTYQtelcNttlKiOyPzMrXHeI-yk1F7-kpDxY4-WY5N
WV5KntaEeXS1j82E375xxhWMHXyvjYecPT9fpwR_M9gV8n9Hrh2anTpTD9
3Dt62ypW3yDsJzBnTnrYu1iwWRgBKrEYY46qAZIrA2xAwnm2X7uGR1hghk
qDp0Vqj3kbSCz1XyfCs6_LehBwtxHIyh8Ripy40p24moOAbgxVw3rxT_vl
t3UVe4WO3JkJOzlpUf-KTVI2Ptgm-dARxTEtE-id-4OJr0h-K-VFs3VSnd
VTIznSxfyrj8ILL6MG_Uv8YAu7VILSB3lOW085-4qE3DzgrTjgyQ",
"p":"1r52Xk46c-LsfB5P442p7atdPUrxQSy4mti_tZI3Mgf2EuFVbUoDBvaRQ-
SWxkbkmoEzL7JXroSBjSrK3YIQgYdMgyAEPTPjXv_hI2_1eTSPVZfzL0lf
fNn03IXqWF5MDFuoUYE0hzb2vhrlN_rKrbfDIwUbTrjjgieRbwC6Cl0",
"q":"wLb35x7hmQWZsWJmB_vle87ihgZ19S8lBEROLIsZG4ayZVe9Hi9gDVCOBm
UDdaDYVTSNx_8Fyw1YYa9XGrGnDew00J28cRUoeBB_jKI1oma0Orv1T9aX
IWxKwd4gvxFImOWr3QRL9KEBRzk2RatUBnmDZJTIAfwTs0g68UZHvtc",
"dp":"ZK-YwE7diUh0qR1tR7w8WHtolDx3MZ_OTowiFvgfeQ3SiresXjm9gZ5KL
hMXvo-uz-KUJWDxS5pFQ_M0evdo1dKiRTjVw_x4NyqyXPM5nULPkcpU827
rnpZzAJKpdhWAgqrXGKAECQH0Xt4taznjnd_zVpAmZZq60WPMBMfKcuE",
"dq":"Dq0gfgJ1DdFGXiLvQEZnuKEN0UUmsJBxkjydc3j4ZYdBiMRAy86x0vHCj
ywcMlYYg4yoC4YZa9hNVcsjqA3FeiL19rk8g6Qn29Tt0cj8qqyFpz9vNDB
UfCAiJVeESOjJDZPYHdHY8v1b-o-Z2X5tvLx-TCekf7oxyeKDUqKWjis",
"qi":"VIMpMYbPf47dT1w_zDUXfPimsSegnMOA1zTaX7aGk_8urY6R8-ZW1FxU7
AlWAyLWybqq6t16VFd7hQd0y6flUK4SlOydB61gwanOsXGOAOv82cHq0E3
eL4HrtZkUuKvnPrMnsUUFlfUdybVzxyjz9JF_XyaY14ardLSjf4L_FNY"
}
<span class="grey">Jones & Hildebrand Standards Track [Page 33]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-34" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
The resulting JWE Encrypted Key value is:
[56, 163, 154, 192, 58, 53, 222, 4, 105, 218, 136, 218, 29, 94, 203,
22, 150, 92, 129, 94, 211, 232, 53, 89, 41, 60, 138, 56, 196, 216,
82, 98, 168, 76, 37, 73, 70, 7, 36, 8, 191, 100, 136, 196, 244, 220,
145, 158, 138, 155, 4, 117, 141, 230, 199, 247, 173, 45, 182, 214,
74, 177, 107, 211, 153, 11, 205, 196, 171, 226, 162, 128, 171, 182,
13, 237, 239, 99, 193, 4, 91, 219, 121, 223, 107, 167, 61, 119, 228,
173, 156, 137, 134, 200, 80, 219, 74, 253, 56, 185, 91, 177, 34, 158,
89, 154, 205, 96, 55, 18, 138, 43, 96, 218, 215, 128, 124, 75, 138,
243, 85, 25, 109, 117, 140, 26, 155, 249, 67, 167, 149, 231, 100, 6,
41, 65, 214, 251, 232, 87, 72, 40, 182, 149, 154, 168, 31, 193, 126,
215, 89, 28, 111, 219, 125, 182, 139, 235, 195, 197, 23, 234, 55, 58,
63, 180, 68, 202, 206, 149, 75, 205, 248, 176, 67, 39, 178, 60, 98,
193, 32, 238, 122, 96, 158, 222, 57, 183, 111, 210, 55, 188, 215,
206, 180, 166, 150, 166, 106, 250, 55, 229, 72, 40, 69, 214, 216,
104, 23, 40, 135, 212, 28, 127, 41, 80, 175, 174, 168, 115, 171, 197,
89, 116, 92, 103, 246, 83, 216, 182, 176, 84, 37, 147, 35, 45, 219,
172, 99, 226, 233, 73, 37, 124, 42, 72, 49, 242, 35, 127, 184, 134,
117, 114, 135, 206]
Encoding this JWE Encrypted Key as BASE64URL(JWE Encrypted Key) gives
this value (with line breaks for display purposes only):
OKOawDo13gRp2ojaHV7LFpZcgV7T6DVZKTyKOMTYUmKoTCVJRgckCL9kiMT03JGe
ipsEdY3mx_etLbbWSrFr05kLzcSr4qKAq7YN7e9jwQRb23nfa6c9d-StnImGyFDb
Sv04uVuxIp5Zms1gNxKKK2Da14B8S4rzVRltdYwam_lDp5XnZAYpQdb76FdIKLaV
mqgfwX7XWRxv2322i-vDxRfqNzo_tETKzpVLzfiwQyeyPGLBIO56YJ7eObdv0je8
1860ppamavo35UgoRdbYaBcoh9QcfylQr66oc6vFWXRcZ_ZT2LawVCWTIy3brGPi
6UklfCpIMfIjf7iGdXKHzg
<span class="h4"><a class="selflink" id="appendix-A.1.4" href="#appendix-A.1.4">A.1.4</a>. Initialization Vector</span>
Generate a random 96-bit JWE Initialization Vector. In this example,
the value is:
[227, 197, 117, 252, 2, 219, 233, 68, 180, 225, 77, 219]
Encoding this JWE Initialization Vector as BASE64URL(JWE
Initialization Vector) gives this value:
48V1_ALb6US04U3b
<span class="grey">Jones & Hildebrand Standards Track [Page 34]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-35" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
<span class="h4"><a class="selflink" id="appendix-A.1.5" href="#appendix-A.1.5">A.1.5</a>. Additional Authenticated Data</span>
Let the Additional Authenticated Data encryption parameter be
ASCII(BASE64URL(UTF8(JWE Protected Header))). This value is:
[101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 83, 85, 48, 69,
116, 84, 48, 70, 70, 85, 67, 73, 115, 73, 109, 86, 117, 89, 121, 73,
54, 73, 107, 69, 121, 78, 84, 90, 72, 81, 48, 48, 105, 102, 81]
<span class="h4"><a class="selflink" id="appendix-A.1.6" href="#appendix-A.1.6">A.1.6</a>. Content Encryption</span>
Perform authenticated encryption on the plaintext with the AES GCM
algorithm using the CEK as the encryption key, the JWE Initialization
Vector, and the Additional Authenticated Data value above, requesting
a 128-bit Authentication Tag output. The resulting ciphertext is:
[229, 236, 166, 241, 53, 191, 115, 196, 174, 43, 73, 109, 39, 122,
233, 96, 140, 206, 120, 52, 51, 237, 48, 11, 190, 219, 186, 80, 111,
104, 50, 142, 47, 167, 59, 61, 181, 127, 196, 21, 40, 82, 242, 32,
123, 143, 168, 226, 73, 216, 176, 144, 138, 247, 106, 60, 16, 205,
160, 109, 64, 63, 192]
The resulting Authentication Tag value is:
[92, 80, 104, 49, 133, 25, 161, 215, 173, 101, 219, 211, 136, 91,
210, 145]
Encoding this JWE Ciphertext as BASE64URL(JWE Ciphertext) gives this
value (with line breaks for display purposes only):
5eym8TW_c8SuK0ltJ3rpYIzOeDQz7TALvtu6UG9oMo4vpzs9tX_EFShS8iB7j6ji
SdiwkIr3ajwQzaBtQD_A
Encoding this JWE Authentication Tag as BASE64URL(JWE Authentication
Tag) gives this value:
XFBoMYUZodetZdvTiFvSkQ
<span class="grey">Jones & Hildebrand Standards Track [Page 35]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-36" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
<span class="h4"><a class="selflink" id="appendix-A.1.7" href="#appendix-A.1.7">A.1.7</a>. Complete Representation</span>
Assemble the final representation: The Compact Serialization of this
result is the string BASE64URL(UTF8(JWE Protected Header)) || '.' ||
BASE64URL(JWE Encrypted Key) || '.' || BASE64URL(JWE Initialization
Vector) || '.' || BASE64URL(JWE Ciphertext) || '.' || BASE64URL(JWE
Authentication Tag).
The final result in this example (with line breaks for display
purposes only) is:
eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ.
OKOawDo13gRp2ojaHV7LFpZcgV7T6DVZKTyKOMTYUmKoTCVJRgckCL9kiMT03JGe
ipsEdY3mx_etLbbWSrFr05kLzcSr4qKAq7YN7e9jwQRb23nfa6c9d-StnImGyFDb
Sv04uVuxIp5Zms1gNxKKK2Da14B8S4rzVRltdYwam_lDp5XnZAYpQdb76FdIKLaV
mqgfwX7XWRxv2322i-vDxRfqNzo_tETKzpVLzfiwQyeyPGLBIO56YJ7eObdv0je8
1860ppamavo35UgoRdbYaBcoh9QcfylQr66oc6vFWXRcZ_ZT2LawVCWTIy3brGPi
6UklfCpIMfIjf7iGdXKHzg.
48V1_ALb6US04U3b.
5eym8TW_c8SuK0ltJ3rpYIzOeDQz7TALvtu6UG9oMo4vpzs9tX_EFShS8iB7j6ji
SdiwkIr3ajwQzaBtQD_A.
XFBoMYUZodetZdvTiFvSkQ
<span class="h4"><a class="selflink" id="appendix-A.1.8" href="#appendix-A.1.8">A.1.8</a>. Validation</span>
This example illustrates the process of creating a JWE with
RSAES-OAEP for key encryption and AES GCM for content encryption.
These results can be used to validate JWE decryption implementations
for these algorithms. Note that since the RSAES-OAEP computation
includes random values, the encryption results above will not be
completely reproducible. However, since the AES GCM computation is
deterministic, the JWE Encrypted Ciphertext values will be the same
for all encryptions performed using these inputs.
<span class="h3"><a class="selflink" id="appendix-A.2" href="#appendix-A.2">A.2</a>. Example JWE using RSAES-PKCS1-v1_5 and AES_128_CBC_HMAC_SHA_256</span>
This example encrypts the plaintext "Live long and prosper." to the
recipient using RSAES-PKCS1-v1_5 for key encryption and
AES_128_CBC_HMAC_SHA_256 for content encryption. The representation
of this plaintext (using JSON array notation) is:
[76, 105, 118, 101, 32, 108, 111, 110, 103, 32, 97, 110, 100, 32,
112, 114, 111, 115, 112, 101, 114, 46]
<span class="grey">Jones & Hildebrand Standards Track [Page 36]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-37" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
<span class="h4"><a class="selflink" id="appendix-A.2.1" href="#appendix-A.2.1">A.2.1</a>. JOSE Header</span>
The following example JWE Protected Header declares that:
o The Content Encryption Key is encrypted to the recipient using the
RSAES-PKCS1-v1_5 algorithm to produce the JWE Encrypted Key.
o Authenticated encryption is performed on the plaintext using the
AES_128_CBC_HMAC_SHA_256 algorithm to produce the ciphertext and
the Authentication Tag.
{"alg":"RSA1_5","enc":"A128CBC-HS256"}
Encoding this JWE Protected Header as BASE64URL(UTF8(JWE Protected
Header)) gives this value:
eyJhbGciOiJSU0ExXzUiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0
<span class="h4"><a class="selflink" id="appendix-A.2.2" href="#appendix-A.2.2">A.2.2</a>. Content Encryption Key (CEK)</span>
Generate a 256-bit random CEK. In this example, the key value is:
[4, 211, 31, 197, 84, 157, 252, 254, 11, 100, 157, 250, 63, 170, 106,
206, 107, 124, 212, 45, 111, 107, 9, 219, 200, 177, 0, 240, 143, 156,
44, 207]
<span class="grey">Jones & Hildebrand Standards Track [Page 37]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-38" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
<span class="h4"><a class="selflink" id="appendix-A.2.3" href="#appendix-A.2.3">A.2.3</a>. Key Encryption</span>
Encrypt the CEK with the recipient's public key using the
RSAES-PKCS1-v1_5 algorithm to produce the JWE Encrypted Key. This
example uses the RSA key represented in JSON Web Key [<a href="#ref-JWK" title=""JSON Web Key (JWK)"">JWK</a>] format
below (with line breaks within values for display purposes only):
{"kty":"RSA",
"n":"sXchDaQebHnPiGvyDOAT4saGEUetSyo9MKLOoWFsueri23bOdgWp4Dy1Wl
UzewbgBHod5pcM9H95GQRV3JDXboIRROSBigeC5yjU1hGzHHyXss8UDpre
cbAYxknTcQkhslANGRUZmdTOQ5qTRsLAt6BTYuyvVRdhS8exSZEy_c4gs_
7svlJJQ4H9_NxsiIoLwAEk7-Q3UXERGYw_75IDrGA84-lA_-Ct4eTlXHBI
Y2EaV7t7LjJaynVJCpkv4LKjTTAumiGUIuQhrNhZLuF_RJLqHpM2kgWFLU
7-VTdL1VbC2tejvcI2BlMkEpk1BzBZI0KQB0GaDWFLN-aEAw3vRw",
"e":"AQAB",
"d":"VFCWOqXr8nvZNyaaJLXdnNPXZKRaWCjkU5Q2egQQpTBMwhprMzWzpR8Sxq
1OPThh_J6MUD8Z35wky9b8eEO0pwNS8xlh1lOFRRBoNqDIKVOku0aZb-ry
nq8cxjDTLZQ6Fz7jSjR1Klop-YKaUHc9GsEofQqYruPhzSA-QgajZGPbE_
0ZaVDJHfyd7UUBUKunFMScbflYAAOYJqVIVwaYR5zWEEceUjNnTNo_CVSj
-VvXLO5VZfCUAVLgW4dpf1SrtZjSt34YLsRarSb127reG_DUwg9Ch-Kyvj
T1SkHgUWRVGcyly7uvVGRSDwsXypdrNinPA4jlhoNdizK2zF2CWQ",
"p":"9gY2w6I6S6L0juEKsbeDAwpd9WMfgqFoeA9vEyEUuk4kLwBKcoe1x4HG68
ik918hdDSE9vDQSccA3xXHOAFOPJ8R9EeIAbTi1VwBYnbTp87X-xcPWlEP
krdoUKW60tgs1aNd_Nnc9LEVVPMS390zbFxt8TN_biaBgelNgbC95sM",
"q":"uKlCKvKv_ZJMVcdIs5vVSU_6cPtYI1ljWytExV_skstvRSNi9r66jdd9-y
BhVfuG4shsp2j7rGnIio901RBeHo6TPKWVVykPu1iYhQXw1jIABfw-MVsN
-3bQ76WLdt2SDxsHs7q7zPyUyHXmps7ycZ5c72wGkUwNOjYelmkiNS0",
"dp":"w0kZbV63cVRvVX6yk3C8cMxo2qCM4Y8nsq1lmMSYhG4EcL6FWbX5h9yuv
ngs4iLEFk6eALoUS4vIWEwcL4txw9LsWH_zKI-hwoReoP77cOdSL4AVcra
Hawlkpyd2TWjE5evgbhWtOxnZee3cXJBkAi64Ik6jZxbvk-RR3pEhnCs",
"dq":"o_8V14SezckO6CNLKs_btPdFiO9_kC1DsuUTd2LAfIIVeMZ7jn1Gus_Ff
7B7IVx3p5KuBGOVF8L-qifLb6nQnLysgHDh132NDioZkhH7mI7hPG-PYE_
odApKdnqECHWw0J-F0JWnUd6D2B_1TvF9mXA2Qx-iGYn8OVV1Bsmp6qU",
"qi":"eNho5yRBEBxhGBtQRww9QirZsB66TrfFReG_CcteI1aCneT0ELGhYlRlC
tUkTRclIfuEPmNsNDPbLoLqqCVznFbvdB7x-Tl-m0l_eFTj2KiqwGqE9PZ
B9nNTwMVvH3VRRSLWACvPnSiwP8N5Usy-WRXS-V7TbpxIhvepTfE0NNo"
}
<span class="grey">Jones & Hildebrand Standards Track [Page 38]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-39" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
The resulting JWE Encrypted Key value is:
[80, 104, 72, 58, 11, 130, 236, 139, 132, 189, 255, 205, 61, 86, 151,
176, 99, 40, 44, 233, 176, 189, 205, 70, 202, 169, 72, 40, 226, 181,
156, 223, 120, 156, 115, 232, 150, 209, 145, 133, 104, 112, 237, 156,
116, 250, 65, 102, 212, 210, 103, 240, 177, 61, 93, 40, 71, 231, 223,
226, 240, 157, 15, 31, 150, 89, 200, 215, 198, 203, 108, 70, 117, 66,
212, 238, 193, 205, 23, 161, 169, 218, 243, 203, 128, 214, 127, 253,
215, 139, 43, 17, 135, 103, 179, 220, 28, 2, 212, 206, 131, 158, 128,
66, 62, 240, 78, 186, 141, 125, 132, 227, 60, 137, 43, 31, 152, 199,
54, 72, 34, 212, 115, 11, 152, 101, 70, 42, 219, 233, 142, 66, 151,
250, 126, 146, 141, 216, 190, 73, 50, 177, 146, 5, 52, 247, 28, 197,
21, 59, 170, 247, 181, 89, 131, 241, 169, 182, 246, 99, 15, 36, 102,
166, 182, 172, 197, 136, 230, 120, 60, 58, 219, 243, 149, 94, 222,
150, 154, 194, 110, 227, 225, 112, 39, 89, 233, 112, 207, 211, 241,
124, 174, 69, 221, 179, 107, 196, 225, 127, 167, 112, 226, 12, 242,
16, 24, 28, 120, 182, 244, 213, 244, 153, 194, 162, 69, 160, 244,
248, 63, 165, 141, 4, 207, 249, 193, 79, 131, 0, 169, 233, 127, 167,
101, 151, 125, 56, 112, 111, 248, 29, 232, 90, 29, 147, 110, 169,
146, 114, 165, 204, 71, 136, 41, 252]
Encoding this JWE Encrypted Key as BASE64URL(JWE Encrypted Key) gives
this value (with line breaks for display purposes only):
UGhIOguC7IuEvf_NPVaXsGMoLOmwvc1GyqlIKOK1nN94nHPoltGRhWhw7Zx0-kFm
1NJn8LE9XShH59_i8J0PH5ZZyNfGy2xGdULU7sHNF6Gp2vPLgNZ__deLKxGHZ7Pc
HALUzoOegEI-8E66jX2E4zyJKx-YxzZIItRzC5hlRirb6Y5Cl_p-ko3YvkkysZIF
NPccxRU7qve1WYPxqbb2Yw8kZqa2rMWI5ng8OtvzlV7elprCbuPhcCdZ6XDP0_F8
rkXds2vE4X-ncOIM8hAYHHi29NX0mcKiRaD0-D-ljQTP-cFPgwCp6X-nZZd9OHBv
-B3oWh2TbqmScqXMR4gp_A
<span class="h4"><a class="selflink" id="appendix-A.2.4" href="#appendix-A.2.4">A.2.4</a>. Initialization Vector</span>
Generate a random 128-bit JWE Initialization Vector. In this
example, the value is:
[3, 22, 60, 12, 43, 67, 104, 105, 108, 108, 105, 99, 111, 116, 104,
101]
Encoding this JWE Initialization Vector as BASE64URL(JWE
Initialization Vector) gives this value:
AxY8DCtDaGlsbGljb3RoZQ
<span class="grey">Jones & Hildebrand Standards Track [Page 39]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-40" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
<span class="h4"><a class="selflink" id="appendix-A.2.5" href="#appendix-A.2.5">A.2.5</a>. Additional Authenticated Data</span>
Let the Additional Authenticated Data encryption parameter be
ASCII(BASE64URL(UTF8(JWE Protected Header))). This value is:
[101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 83, 85, 48, 69,
120, 88, 122, 85, 105, 76, 67, 74, 108, 98, 109, 77, 105, 79, 105,
74, 66, 77, 84, 73, 52, 81, 48, 74, 68, 76, 85, 104, 84, 77, 106, 85,
50, 73, 110, 48]
<span class="h4"><a class="selflink" id="appendix-A.2.6" href="#appendix-A.2.6">A.2.6</a>. Content Encryption</span>
Perform authenticated encryption on the plaintext with the
AES_128_CBC_HMAC_SHA_256 algorithm using the CEK as the encryption
key, the JWE Initialization Vector, and the Additional Authenticated
Data value above. The steps for doing this using the values from
<a href="#appendix-A.3">Appendix A.3</a> are detailed in <a href="#appendix-B">Appendix B</a>. The resulting ciphertext
is:
[40, 57, 83, 181, 119, 33, 133, 148, 198, 185, 243, 24, 152, 230, 6,
75, 129, 223, 127, 19, 210, 82, 183, 230, 168, 33, 215, 104, 143,
112, 56, 102]
The resulting Authentication Tag value is:
[246, 17, 244, 190, 4, 95, 98, 3, 231, 0, 115, 157, 242, 203, 100,
191]
Encoding this JWE Ciphertext as BASE64URL(JWE Ciphertext) gives this
value:
KDlTtXchhZTGufMYmOYGS4HffxPSUrfmqCHXaI9wOGY
Encoding this JWE Authentication Tag as BASE64URL(JWE Authentication
Tag) gives this value:
9hH0vgRfYgPnAHOd8stkvw
<span class="h4"><a class="selflink" id="appendix-A.2.7" href="#appendix-A.2.7">A.2.7</a>. Complete Representation</span>
Assemble the final representation: The Compact Serialization of this
result is the string BASE64URL(UTF8(JWE Protected Header)) || '.' ||
BASE64URL(JWE Encrypted Key) || '.' || BASE64URL(JWE Initialization
Vector) || '.' || BASE64URL(JWE Ciphertext) || '.' || BASE64URL(JWE
Authentication Tag).
<span class="grey">Jones & Hildebrand Standards Track [Page 40]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-41" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
The final result in this example (with line breaks for display
purposes only) is:
eyJhbGciOiJSU0ExXzUiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0.
UGhIOguC7IuEvf_NPVaXsGMoLOmwvc1GyqlIKOK1nN94nHPoltGRhWhw7Zx0-kFm
1NJn8LE9XShH59_i8J0PH5ZZyNfGy2xGdULU7sHNF6Gp2vPLgNZ__deLKxGHZ7Pc
HALUzoOegEI-8E66jX2E4zyJKx-YxzZIItRzC5hlRirb6Y5Cl_p-ko3YvkkysZIF
NPccxRU7qve1WYPxqbb2Yw8kZqa2rMWI5ng8OtvzlV7elprCbuPhcCdZ6XDP0_F8
rkXds2vE4X-ncOIM8hAYHHi29NX0mcKiRaD0-D-ljQTP-cFPgwCp6X-nZZd9OHBv
-B3oWh2TbqmScqXMR4gp_A.
AxY8DCtDaGlsbGljb3RoZQ.
KDlTtXchhZTGufMYmOYGS4HffxPSUrfmqCHXaI9wOGY.
9hH0vgRfYgPnAHOd8stkvw
<span class="h4"><a class="selflink" id="appendix-A.2.8" href="#appendix-A.2.8">A.2.8</a>. Validation</span>
This example illustrates the process of creating a JWE with
RSAES-PKCS1-v1_5 for key encryption and AES_CBC_HMAC_SHA2 for content
encryption. These results can be used to validate JWE decryption
implementations for these algorithms. Note that since the
RSAES-PKCS1-v1_5 computation includes random values, the encryption
results above will not be completely reproducible. However, since
the AES-CBC computation is deterministic, the JWE Encrypted
Ciphertext values will be the same for all encryptions performed
using these inputs.
<span class="h3"><a class="selflink" id="appendix-A.3" href="#appendix-A.3">A.3</a>. Example JWE Using AES Key Wrap and AES_128_CBC_HMAC_SHA_256</span>
This example encrypts the plaintext "Live long and prosper." to the
recipient using AES Key Wrap for key encryption and
AES_128_CBC_HMAC_SHA_256 for content encryption. The representation
of this plaintext (using JSON array notation) is:
[76, 105, 118, 101, 32, 108, 111, 110, 103, 32, 97, 110, 100, 32,
112, 114, 111, 115, 112, 101, 114, 46]
<span class="h4"><a class="selflink" id="appendix-A.3.1" href="#appendix-A.3.1">A.3.1</a>. JOSE Header</span>
The following example JWE Protected Header declares that:
o The Content Encryption Key is encrypted to the recipient using the
AES Key Wrap algorithm with a 128-bit key to produce the JWE
Encrypted Key.
o Authenticated encryption is performed on the plaintext using the
AES_128_CBC_HMAC_SHA_256 algorithm to produce the ciphertext and
the Authentication Tag.
{"alg":"A128KW","enc":"A128CBC-HS256"}
<span class="grey">Jones & Hildebrand Standards Track [Page 41]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-42" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
Encoding this JWE Protected Header as BASE64URL(UTF8(JWE Protected
Header)) gives this value:
eyJhbGciOiJBMTI4S1ciLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0
<span class="h4"><a class="selflink" id="appendix-A.3.2" href="#appendix-A.3.2">A.3.2</a>. Content Encryption Key (CEK)</span>
Generate a 256-bit random CEK. In this example, the value is:
[4, 211, 31, 197, 84, 157, 252, 254, 11, 100, 157, 250, 63, 170, 106,
206, 107, 124, 212, 45, 111, 107, 9, 219, 200, 177, 0, 240, 143, 156,
44, 207]
<span class="h4"><a class="selflink" id="appendix-A.3.3" href="#appendix-A.3.3">A.3.3</a>. Key Encryption</span>
Encrypt the CEK with the shared symmetric key using the AES Key Wrap
algorithm to produce the JWE Encrypted Key. This example uses the
symmetric key represented in JSON Web Key [<a href="#ref-JWK" title=""JSON Web Key (JWK)"">JWK</a>] format below:
{"kty":"oct",
"k":"GawgguFyGrWKav7AX4VKUg"
}
The resulting JWE Encrypted Key value is:
[232, 160, 123, 211, 183, 76, 245, 132, 200, 128, 123, 75, 190, 216,
22, 67, 201, 138, 193, 186, 9, 91, 122, 31, 246, 90, 28, 139, 57, 3,
76, 124, 193, 11, 98, 37, 173, 61, 104, 57]
Encoding this JWE Encrypted Key as BASE64URL(JWE Encrypted Key) gives
this value:
6KB707dM9YTIgHtLvtgWQ8mKwboJW3of9locizkDTHzBC2IlrT1oOQ
<span class="h4"><a class="selflink" id="appendix-A.3.4" href="#appendix-A.3.4">A.3.4</a>. Initialization Vector</span>
Generate a random 128-bit JWE Initialization Vector. In this
example, the value is:
[3, 22, 60, 12, 43, 67, 104, 105, 108, 108, 105, 99, 111, 116, 104,
101]
Encoding this JWE Initialization Vector as BASE64URL(JWE
Initialization Vector) gives this value:
AxY8DCtDaGlsbGljb3RoZQ
<span class="grey">Jones & Hildebrand Standards Track [Page 42]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-43" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
<span class="h4"><a class="selflink" id="appendix-A.3.5" href="#appendix-A.3.5">A.3.5</a>. Additional Authenticated Data</span>
Let the Additional Authenticated Data encryption parameter be
ASCII(BASE64URL(UTF8(JWE Protected Header))). This value is:
[101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 66, 77, 84, 73, 52,
83, 49, 99, 105, 76, 67, 74, 108, 98, 109, 77, 105, 79, 105, 74, 66,
77, 84, 73, 52, 81, 48, 74, 68, 76, 85, 104, 84, 77, 106, 85, 50, 73,
110, 48]
<span class="h4"><a class="selflink" id="appendix-A.3.6" href="#appendix-A.3.6">A.3.6</a>. Content Encryption</span>
Perform authenticated encryption on the plaintext with the
AES_128_CBC_HMAC_SHA_256 algorithm using the CEK as the encryption
key, the JWE Initialization Vector, and the Additional Authenticated
Data value above. The steps for doing this using the values from
this example are detailed in <a href="#appendix-B">Appendix B</a>. The resulting ciphertext
is:
[40, 57, 83, 181, 119, 33, 133, 148, 198, 185, 243, 24, 152, 230, 6,
75, 129, 223, 127, 19, 210, 82, 183, 230, 168, 33, 215, 104, 143,
112, 56, 102]
The resulting Authentication Tag value is:
[83, 73, 191, 98, 104, 205, 211, 128, 201, 189, 199, 133, 32, 38,
194, 85]
Encoding this JWE Ciphertext as BASE64URL(JWE Ciphertext) gives this
value:
KDlTtXchhZTGufMYmOYGS4HffxPSUrfmqCHXaI9wOGY
Encoding this JWE Authentication Tag as BASE64URL(JWE Authentication
Tag) gives this value:
U0m_YmjN04DJvceFICbCVQ
<span class="h4"><a class="selflink" id="appendix-A.3.7" href="#appendix-A.3.7">A.3.7</a>. Complete Representation</span>
Assemble the final representation: The Compact Serialization of this
result is the string BASE64URL(UTF8(JWE Protected Header)) || '.' ||
BASE64URL(JWE Encrypted Key) || '.' || BASE64URL(JWE Initialization
Vector) || '.' || BASE64URL(JWE Ciphertext) || '.' || BASE64URL(JWE
Authentication Tag).
<span class="grey">Jones & Hildebrand Standards Track [Page 43]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-44" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
The final result in this example (with line breaks for display
purposes only) is:
eyJhbGciOiJBMTI4S1ciLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0.
6KB707dM9YTIgHtLvtgWQ8mKwboJW3of9locizkDTHzBC2IlrT1oOQ.
AxY8DCtDaGlsbGljb3RoZQ.
KDlTtXchhZTGufMYmOYGS4HffxPSUrfmqCHXaI9wOGY.
U0m_YmjN04DJvceFICbCVQ
<span class="h4"><a class="selflink" id="appendix-A.3.8" href="#appendix-A.3.8">A.3.8</a>. Validation</span>
This example illustrates the process of creating a JWE with AES Key
Wrap for key encryption and AES GCM for content encryption. These
results can be used to validate JWE decryption implementations for
these algorithms. Also, since both the AES Key Wrap and AES GCM
computations are deterministic, the resulting JWE value will be the
same for all encryptions performed using these inputs. Since the
computation is reproducible, these results can also be used to
validate JWE encryption implementations for these algorithms.
<span class="h3"><a class="selflink" id="appendix-A.4" href="#appendix-A.4">A.4</a>. Example JWE Using General JWE JSON Serialization</span>
This section contains an example using the general JWE JSON
Serialization syntax. This example demonstrates the capability for
encrypting the same plaintext to multiple recipients.
Two recipients are present in this example. The algorithm and key
used for the first recipient are the same as that used in
<a href="#appendix-A.2">Appendix A.2</a>. The algorithm and key used for the second recipient
are the same as that used in <a href="#appendix-A.3">Appendix A.3</a>. The resulting JWE
Encrypted Key values are therefore the same; those computations are
not repeated here.
The plaintext, the CEK, JWE Initialization Vector, and JWE Protected
Header are shared by all recipients (which must be the case, since
the ciphertext and Authentication Tag are also shared).
<span class="grey">Jones & Hildebrand Standards Track [Page 44]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-45" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
<span class="h4"><a class="selflink" id="appendix-A.4.1" href="#appendix-A.4.1">A.4.1</a>. JWE Per-Recipient Unprotected Headers</span>
The first recipient uses the RSAES-PKCS1-v1_5 algorithm to encrypt
the CEK. The second uses AES Key Wrap to encrypt the CEK. Key ID
values are supplied for both keys. The two JWE Per-Recipient
Unprotected Header values used to represent these algorithms and key
IDs are:
{"alg":"RSA1_5","kid":"2011-04-29"}
and
{"alg":"A128KW","kid":"7"}
<span class="h4"><a class="selflink" id="appendix-A.4.2" href="#appendix-A.4.2">A.4.2</a>. JWE Protected Header</span>
Authenticated encryption is performed on the plaintext using the
AES_128_CBC_HMAC_SHA_256 algorithm to produce the common JWE
Ciphertext and JWE Authentication Tag values. The JWE Protected
Header value representing this is:
{"enc":"A128CBC-HS256"}
Encoding this JWE Protected Header as BASE64URL(UTF8(JWE Protected
Header)) gives this value:
eyJlbmMiOiJBMTI4Q0JDLUhTMjU2In0
<span class="h4"><a class="selflink" id="appendix-A.4.3" href="#appendix-A.4.3">A.4.3</a>. JWE Shared Unprotected Header</span>
This JWE uses the "jku" Header Parameter to reference a JWK Set.
This is represented in the following JWE Shared Unprotected Header
value as:
{"jku":"https://server.example.com/keys.jwks"}
<span class="h4"><a class="selflink" id="appendix-A.4.4" href="#appendix-A.4.4">A.4.4</a>. Complete JOSE Header Values</span>
Combining the JWE Per-Recipient Unprotected Header, JWE Protected
Header, and JWE Shared Unprotected Header values supplied, the JOSE
Header values used for the first and second recipient, respectively,
are:
{"alg":"RSA1_5",
"kid":"2011-04-29",
"enc":"A128CBC-HS256",
"jku":"https://server.example.com/keys.jwks"}
<span class="grey">Jones & Hildebrand Standards Track [Page 45]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-46" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
and
{"alg":"A128KW",
"kid":"7",
"enc":"A128CBC-HS256",
"jku":"https://server.example.com/keys.jwks"}
<span class="h4"><a class="selflink" id="appendix-A.4.5" href="#appendix-A.4.5">A.4.5</a>. Additional Authenticated Data</span>
Let the Additional Authenticated Data encryption parameter be
ASCII(BASE64URL(UTF8(JWE Protected Header))). This value is:
[101, 121, 74, 108, 98, 109, 77, 105, 79, 105, 74, 66, 77, 84, 73,
52, 81, 48, 74, 68, 76, 85, 104, 84, 77, 106, 85, 50, 73, 110, 48]
<span class="h4"><a class="selflink" id="appendix-A.4.6" href="#appendix-A.4.6">A.4.6</a>. Content Encryption</span>
Perform authenticated encryption on the plaintext with the
AES_128_CBC_HMAC_SHA_256 algorithm using the CEK as the encryption
key, the JWE Initialization Vector, and the Additional Authenticated
Data value above. The steps for doing this using the values from
<a href="#appendix-A.3">Appendix A.3</a> are detailed in <a href="#appendix-B">Appendix B</a>. The resulting ciphertext
is:
[40, 57, 83, 181, 119, 33, 133, 148, 198, 185, 243, 24, 152, 230, 6,
75, 129, 223, 127, 19, 210, 82, 183, 230, 168, 33, 215, 104, 143,
112, 56, 102]
The resulting Authentication Tag value is:
[51, 63, 149, 60, 252, 148, 225, 25, 92, 185, 139, 245, 35, 2, 47,
207]
Encoding this JWE Ciphertext as BASE64URL(JWE Ciphertext) gives this
value:
KDlTtXchhZTGufMYmOYGS4HffxPSUrfmqCHXaI9wOGY
Encoding this JWE Authentication Tag as BASE64URL(JWE Authentication
Tag) gives this value:
Mz-VPPyU4RlcuYv1IwIvzw
<span class="grey">Jones & Hildebrand Standards Track [Page 46]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-47" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
<span class="h4"><a class="selflink" id="appendix-A.4.7" href="#appendix-A.4.7">A.4.7</a>. Complete JWE JSON Serialization Representation</span>
The complete JWE JSON Serialization for these values is as follows
(with line breaks within values for display purposes only):
{
"protected":
"eyJlbmMiOiJBMTI4Q0JDLUhTMjU2In0",
"unprotected":
{"jku":"https://server.example.com/keys.jwks"},
"recipients":[
{"header":
{"alg":"RSA1_5","kid":"2011-04-29"},
"encrypted_key":
"UGhIOguC7IuEvf_NPVaXsGMoLOmwvc1GyqlIKOK1nN94nHPoltGRhWhw7Zx0-
kFm1NJn8LE9XShH59_i8J0PH5ZZyNfGy2xGdULU7sHNF6Gp2vPLgNZ__deLKx
GHZ7PcHALUzoOegEI-8E66jX2E4zyJKx-YxzZIItRzC5hlRirb6Y5Cl_p-ko3
YvkkysZIFNPccxRU7qve1WYPxqbb2Yw8kZqa2rMWI5ng8OtvzlV7elprCbuPh
cCdZ6XDP0_F8rkXds2vE4X-ncOIM8hAYHHi29NX0mcKiRaD0-D-ljQTP-cFPg
wCp6X-nZZd9OHBv-B3oWh2TbqmScqXMR4gp_A"},
{"header":
{"alg":"A128KW","kid":"7"},
"encrypted_key":
"6KB707dM9YTIgHtLvtgWQ8mKwboJW3of9locizkDTHzBC2IlrT1oOQ"}],
"iv":
"AxY8DCtDaGlsbGljb3RoZQ",
"ciphertext":
"KDlTtXchhZTGufMYmOYGS4HffxPSUrfmqCHXaI9wOGY",
"tag":
"Mz-VPPyU4RlcuYv1IwIvzw"
}
<span class="h3"><a class="selflink" id="appendix-A.5" href="#appendix-A.5">A.5</a>. Example JWE Using Flattened JWE JSON Serialization</span>
This section contains an example using the flattened JWE JSON
Serialization syntax. This example demonstrates the capability for
encrypting the plaintext to a single recipient in a flattened JSON
structure.
The values in this example are the same as those for the second
recipient of the previous example in <a href="#appendix-A.4">Appendix A.4</a>.
<span class="grey">Jones & Hildebrand Standards Track [Page 47]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-48" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
The complete JWE JSON Serialization for these values is as follows
(with line breaks within values for display purposes only):
{
"protected":
"eyJlbmMiOiJBMTI4Q0JDLUhTMjU2In0",
"unprotected":
{"jku":"https://server.example.com/keys.jwks"},
"header":
{"alg":"A128KW","kid":"7"},
"encrypted_key":
"6KB707dM9YTIgHtLvtgWQ8mKwboJW3of9locizkDTHzBC2IlrT1oOQ",
"iv":
"AxY8DCtDaGlsbGljb3RoZQ",
"ciphertext":
"KDlTtXchhZTGufMYmOYGS4HffxPSUrfmqCHXaI9wOGY",
"tag":
"Mz-VPPyU4RlcuYv1IwIvzw"
}
<span class="h2"><a class="selflink" id="appendix-B" href="#appendix-B">Appendix B</a>. Example AES_128_CBC_HMAC_SHA_256 Computation</span>
This example shows the steps in the AES_128_CBC_HMAC_SHA_256
authenticated encryption computation using the values from the
example in <a href="#appendix-A.3">Appendix A.3</a>. As described where this algorithm is
defined in Sections <a href="#section-5.2">5.2</a> and <a href="#section-5.2.3">5.2.3</a> of JWA, the AES_CBC_HMAC_SHA2
family of algorithms are implemented using Advanced Encryption
Standard (AES) in Cipher Block Chaining (CBC) mode with Public-Key
Cryptography Standards (PKCS) #7 padding to perform the encryption
and an HMAC SHA-2 function to perform the integrity calculation -- in
this case, HMAC SHA-256.
<span class="h3"><a class="selflink" id="appendix-B.1" href="#appendix-B.1">B.1</a>. Extract MAC_KEY and ENC_KEY from Key</span>
The 256 bit AES_128_CBC_HMAC_SHA_256 key K used in this example
(using JSON array notation) is:
[4, 211, 31, 197, 84, 157, 252, 254, 11, 100, 157, 250, 63, 170, 106,
206, 107, 124, 212, 45, 111, 107, 9, 219, 200, 177, 0, 240, 143, 156,
44, 207]
Use the first 128 bits of this key as the HMAC SHA-256 key MAC_KEY,
which is:
[4, 211, 31, 197, 84, 157, 252, 254, 11, 100, 157, 250, 63, 170, 106,
206]
<span class="grey">Jones & Hildebrand Standards Track [Page 48]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-49" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
Use the last 128 bits of this key as the AES-CBC key ENC_KEY, which
is:
[107, 124, 212, 45, 111, 107, 9, 219, 200, 177, 0, 240, 143, 156, 44,
207]
Note that the MAC key comes before the encryption key in the input
key K; this is in the opposite order of the algorithm names in the
identifiers "AES_128_CBC_HMAC_SHA_256" and "A128CBC-HS256".
<span class="h3"><a class="selflink" id="appendix-B.2" href="#appendix-B.2">B.2</a>. Encrypt Plaintext to Create Ciphertext</span>
Encrypt the plaintext with AES in CBC mode using PKCS #7 padding
using the ENC_KEY above. The plaintext in this example is:
[76, 105, 118, 101, 32, 108, 111, 110, 103, 32, 97, 110, 100, 32,
112, 114, 111, 115, 112, 101, 114, 46]
The encryption result is as follows, which is the ciphertext output:
[40, 57, 83, 181, 119, 33, 133, 148, 198, 185, 243, 24, 152, 230, 6,
75, 129, 223, 127, 19, 210, 82, 183, 230, 168, 33, 215, 104, 143,
112, 56, 102]
<span class="h3"><a class="selflink" id="appendix-B.3" href="#appendix-B.3">B.3</a>. 64-Bit Big-Endian Representation of AAD Length</span>
The Additional Authenticated Data (AAD) in this example is:
[101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 66, 77, 84, 73, 52,
83, 49, 99, 105, 76, 67, 74, 108, 98, 109, 77, 105, 79, 105, 74, 66,
77, 84, 73, 52, 81, 48, 74, 68, 76, 85, 104, 84, 77, 106, 85, 50, 73,
110, 48]
This AAD is 51-bytes long, which is 408-bits long. The octet string
AL, which is the number of bits in AAD expressed as a big-endian
64-bit unsigned integer is:
[0, 0, 0, 0, 0, 0, 1, 152]
<span class="h3"><a class="selflink" id="appendix-B.4" href="#appendix-B.4">B.4</a>. Initialization Vector Value</span>
The Initialization Vector value used in this example is:
[3, 22, 60, 12, 43, 67, 104, 105, 108, 108, 105, 99, 111, 116, 104,
101]
<span class="grey">Jones & Hildebrand Standards Track [Page 49]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-50" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
<span class="h3"><a class="selflink" id="appendix-B.5" href="#appendix-B.5">B.5</a>. Create Input to HMAC Computation</span>
Concatenate the AAD, the Initialization Vector, the ciphertext, and
the AL value. The result of this concatenation is:
[101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 66, 77, 84, 73, 52,
83, 49, 99, 105, 76, 67, 74, 108, 98, 109, 77, 105, 79, 105, 74, 66,
77, 84, 73, 52, 81, 48, 74, 68, 76, 85, 104, 84, 77, 106, 85, 50, 73,
110, 48, 3, 22, 60, 12, 43, 67, 104, 105, 108, 108, 105, 99, 111,
116, 104, 101, 40, 57, 83, 181, 119, 33, 133, 148, 198, 185, 243, 24,
152, 230, 6, 75, 129, 223, 127, 19, 210, 82, 183, 230, 168, 33, 215,
104, 143, 112, 56, 102, 0, 0, 0, 0, 0, 0, 1, 152]
<span class="h3"><a class="selflink" id="appendix-B.6" href="#appendix-B.6">B.6</a>. Compute HMAC Value</span>
Compute the HMAC SHA-256 of the concatenated value above. This
result M is:
[83, 73, 191, 98, 104, 205, 211, 128, 201, 189, 199, 133, 32, 38,
194, 85, 9, 84, 229, 201, 219, 135, 44, 252, 145, 102, 179, 140, 105,
86, 229, 116]
<span class="h3"><a class="selflink" id="appendix-B.7" href="#appendix-B.7">B.7</a>. Truncate HMAC Value to Create Authentication Tag</span>
Use the first half (128 bits) of the HMAC output M as the
Authentication Tag output T. This truncated value is:
[83, 73, 191, 98, 104, 205, 211, 128, 201, 189, 199, 133, 32, 38,
194, 85]
Acknowledgements
Solutions for encrypting JSON content were also explored by "JSON
Simple Encryption" [<a href="#ref-JSE" title=""JSON Simple Encryption"">JSE</a>] and "JavaScript Message Security Format"
[<a href="#ref-JSMS" title=""JavaScript Message Security Format"">JSMS</a>], both of which significantly influenced this document. This
document attempts to explicitly reuse as many of the relevant
concepts from XML Encryption 1.1 [<a href="#ref-W3C.REC-xmlenc-core1-20130411">W3C.REC-xmlenc-core1-20130411</a>] and
<a href="./rfc5652">RFC 5652</a> [<a href="./rfc5652" title=""Cryptographic Message Syntax (CMS)"">RFC5652</a>] as possible, while utilizing simple, compact JSON-
based data structures.
Special thanks are due to John Bradley, Eric Rescorla, and Nat
Sakimura for the discussions that helped inform the content of this
specification; to Eric Rescorla and Joe Hildebrand for allowing the
reuse of text from [<a href="#ref-JSMS" title=""JavaScript Message Security Format"">JSMS</a>] in this document; and to Eric Rescorla for
co-authoring many drafts of this specification.
Thanks to Axel Nennker, Emmanuel Raviart, Brian Campbell, and Edmund
Jay for validating the examples in this specification.
<span class="grey">Jones & Hildebrand Standards Track [Page 50]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-51" ></span>
<span class="grey"><a href="./rfc7516">RFC 7516</a> JSON Web Encryption (JWE) May 2015</span>
This specification is the work of the JOSE working group, which
includes dozens of active and dedicated participants. In particular,
the following individuals contributed ideas, feedback, and wording
that influenced this specification:
Richard Barnes, John Bradley, Brian Campbell, Alissa Cooper, Breno de
Medeiros, Stephen Farrell, Dick Hardt, Jeff Hodges, Russ Housley,
Edmund Jay, Scott Kelly, Stephen Kent, Barry Leiba, James Manger,
Matt Miller, Kathleen Moriarty, Tony Nadalin, Hideki Nara, Axel
Nennker, Ray Polk, Emmanuel Raviart, Eric Rescorla, Pete Resnick, Nat
Sakimura, Jim Schaad, Hannes Tschofenig, and Sean Turner.
Jim Schaad and Karen O'Donoghue chaired the JOSE working group and
Sean Turner, Stephen Farrell, and Kathleen Moriarty served as
Security Area Directors during the creation of this specification.
Authors' Addresses
Michael B. Jones
Microsoft
EMail: mbj@microsoft.com
URI: <a href="http://self-issued.info/">http://self-issued.info/</a>
Joe Hildebrand
Cisco Systems, Inc.
EMail: jhildebr@cisco.com
Jones & Hildebrand Standards Track [Page 51]
</pre>
|