Commit message (Collapse) | Author | Age | Files | Lines | |
---|---|---|---|---|---|
* | Future proofing use of the six python version constants (#4238) | Eric Brown | 2018-05-14 | 2 | -25/+25 |
| | | | | | | | | | | | | | | | * Future proofing use of the six python version constants After reading [1], noticed that cryptography uses a lot of if six.PY3 blocks. The issue with this is that whenever Python 4 is released, this code in the else block will be executed even though it was only intended for Python 2. [1] http://astrofrog.github.io/blog/2016/01/12/stop-writing-python-4-incompatible-code/ Signed-off-by: Eric Brown <browne@vmware.com> * Use not PY2 instead | ||||
* | Validate the public/private halves of EC keys on import. (#4241) | David Benjamin | 2018-05-14 | 1 | -3/+3 |
| | | | | | | | | | | | | | | | | | | * Validate the public/private halves of EC keys on import. OpenSSL's API is a little finicky. If one sets the public key before the private key, it does not validate that they match. If set in the other order, it does validate this. In particular, KASValidityTest_ECCStaticUnified_NOKC_ZZOnly_init.fax describes error code 7 as: Result = F (7 - IUT's Static private key d changed-prikey validity) Reordering the two operations makes those tests to fail on key import, which is what CAVP appears to have intended. * Wrap to 79 rather than 80 columns | ||||
* | Add support for extracting timestamp from a Fernet token (#4229) | Paul Kehrer | 2018-05-12 | 1 | -0/+9 |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add API for retrieving the seconds-to-expiry for the token, given a TTL. * Process PR feedback: * Do compute the TTL, but just the age of the token. The caller can decided what to do next. * Factored out the HMAC signature verification to a separate function. * Fixed a copy&paste mistake in the test cases * Tests cleanup. * `struct` no longer needed * Document `def age()` * typo in `age()` documentation * token, not data * remove test for TTL expiry that is already covered by the parameterized `test_invalid()`. * let's call this extract_timestamp and just return timestamp * review comments * it's UNIX I know this | ||||
* | Raise ve on bad gt (#4180) | Joshua Crowgey | 2018-04-03 | 1 | -0/+12 |
| | | | | | | | | | | | | | | | * Raise a ValueError when conversion to generalizedtime fails * added test for badasn1time value error * pep8 compliance * Addressing code review + VE now raises with ```{!r}``` formatting + Test now checks that the bad string made it into the VE message * using ValueError.match | ||||
* | fix bug with n % 8 length wrapping on AESKWP (#4160) | Paul Kehrer | 2018-03-20 | 1 | -0/+24 |
| | | | | | | * fix bug with n % 8 length wrapping on AESKWP * review feedback | ||||
* | Revert "don't allow GeneralNames to be an empty list (#4128)" (#4161) | Alex Gaynor | 2018-03-20 | 1 | -4/+0 |
| | | | | | This breaks the urllib3 tests, as well as several in-the-wild certs This reverts commit 388d1bd3e9cd953fcc948edbc152d5d140c87eb8. | ||||
* | implement AES KW with padding (RFC 5649) (#3880) | Paul Kehrer | 2018-03-18 | 1 | -0/+65 |
| | | | | | | | | | | | | | | | | | | * implement AES KW with padding (RFC 5649) fixes #3791 * oops, 2.2 * make sure this is the right valueerror * more match * make key padding easier to read * review feedback * review feedback | ||||
* | Allow DSA q=224 (#4147) | Paul Kehrer | 2018-03-18 | 2 | -91/+18 |
| | | | | | | | | * load Q=224 vectors * DSA parameters should support 224 for q length * oxford comma | ||||
* | Brainpool curves (#4129) | Paul Kehrer | 2018-03-15 | 1 | -1/+28 |
| | | | | | | | | | | | | | | | | | | * added brainpool ec-curves key_length >= 256bit * limit brainpool curves to the set that appear required + docs * oops * typos all around me * add brainpool ECDH kex tests * switch to using rfc 7027 vectors * review feedback * empty commits are the best | ||||
* | don't allow GeneralNames to be an empty list (#4128) | Paul Kehrer | 2018-03-05 | 1 | -0/+4 |
| | | | | | | * don't allow GeneralNames to be an empty list * flake8 | ||||
* | fix a memory leak in ec derive_private_key (#4096) | Paul Kehrer | 2018-02-04 | 1 | -0/+8 |
| | | | | | | | | * fix a memory leak in ec derive_private_key fixes #4095 * pep8! | ||||
* | Fixes #4076 - simplify the implementation of int_from_bytes on python2 (#4077) | Alex Gaynor | 2018-01-10 | 1 | -0/+2 |
| | | | | | | | | * Fixes #4076 - simplify the implementation of int_from_bytes on python2 * whitespace * Added a test | ||||
* | The HKDF limit is actually 255 * digest_length_in_bytes (#4037) | Paul Kehrer | 2018-01-06 | 1 | -2/+20 |
| | | | | | | | | | | | * The HKDF limit is actually 255 * digest_length_in_bytes Previously we had a bug where we divided digest_size by 8...but HashAlgorithm.digest_size is already in bytes. * test longer output * changelog | ||||
* | Expose `BN_clear_free` in the OpenSSL backend (#4071) | Tux | 2018-01-05 | 1 | -1/+1 |
| | | | | | | * Expose BN_clear_free * Use BN_clear_free in test_int_to_bn | ||||
* | Fixed #4058 -- use the thread-safe API from OpenSSL, not the danger one (#4059) | Alex Gaynor | 2017-12-18 | 1 | -3/+3 |
| | |||||
* | Fixed 120 warnings from the RSA tests (#4052) | Alex Gaynor | 2017-12-11 | 1 | -9/+6 |
| | | | | | | * Fixed 120 warnings from the RSA tests * typo | ||||
* | Fixed DSA tests to not emit 200 warnings (#4050) | Alex Gaynor | 2017-12-10 | 1 | -8/+2 |
| | |||||
* | update the ec tests to not emit 3000 warnings (#4048) | Alex Gaynor | 2017-12-10 | 1 | -11/+12 |
| | |||||
* | `iptables-persistent` package (see [here](http://www.microhowto.info/howto/make_the_configuration_of_iptables_persistent_on_debian.html)). ### 4. Fire up mitmproxy. You probably want a command like this: {{< highlight bash >}} mitmproxy --mode transparent --showhost {{< / highlight >}} The `--mode transparent` option turns on transparent mode, and the `--showhost` argument tells mitmproxy to use the value of the Host header for URL display. ### 5. Finally, configure your test device. Set the test device up to use the host on which mitmproxy is running as the default gateway and [install the mitmproxy certificate authority on the test device]({{< relref "concepts-certificates" >}}). ## OpenBSD ### 1. Enable IP forwarding. {{< highlight bash >}} sudo sysctl -w net.inet.ip.forwarding=1 {{< / highlight >}} ### 2. Place the following two lines in **/etc/pf.conf**. {{< highlight none >}} mitm_if = "re2" pass in quick proto tcp from $mitm_if to port { 80, 443 } divert-to 127.0.0.1 port 8080 {{< / highlight >}} These rules tell pf to divert all traffic from `$mitm_if` destined for port 80 or 443 to the local mitmproxy instance running on port 8080. You should replace `$mitm_if` value with the interface on which your test device will appear. ### 3. Configure pf with the rules. {{< highlight bash >}} doas pfctl -f /etc/pf.conf {{< / highlight >}} ### 4. And now enable it. {{< highlight bash >}} doas pfctl -e {{< / highlight >}} ### 5. Fire up mitmproxy. You probably want a command like this: {{< highlight bash >}} mitmproxy --mode transparent --showhost {{< / highlight >}} The `--mode transparent` option turns on transparent mode, and the `--showhost` argument tells mitmproxy to use the value of the Host header for URL display. ### 6. Finally, configure your test device. Set the test device up to use the host on which mitmproxy is running as the default gateway and [install the mitmproxy certificate authority on the test device]({{< relref "concepts-certificates" >}}). {{% note %}} Note that the **divert-to** rules in the pf.conf given above only apply to inbound traffic. **This means that they will NOT redirect traffic coming from the box running pf itself.** We can't distinguish between an outbound connection from a non-mitmproxy app, and an outbound connection from mitmproxy itself - if you want to intercept your traffic, you should use an external host to run mitmproxy. Nonetheless, pf is flexible to cater for a range of creative possibilities, like intercepting traffic emanating from VMs. See the **pf.conf** man page for more. {{% /note %}} ## macOS OSX Lion integrated the [pf](https://en.wikipedia.org/wiki/PF_(firewall)) packet filter from the OpenBSD project, which mitmproxy uses to implement transparent mode on OSX. Note that this means we don't support transparent mode for earlier versions of OSX. ### 1. Enable IP forwarding. {{< highlight bash >}} sudo sysctl -w net.inet.ip.forwarding=1 {{< / highlight >}} ### 2. Place the following two lines in a file called, say, **pf.conf**. {{< highlight none >}} rdr on en0 inet proto tcp to any port {80, 443} -> 127.0.0.1 port 8080 {{< / highlight >}} These rules tell pf to redirect all traffic destined for port 80 or 443 to the local mitmproxy instance running on port 8080. You should replace `en0` with the interface on which your test device will appear. ### 3. Configure pf with the rules. {{< highlight bash >}} sudo pfctl -f pf.conf {{< / highlight >}} ### 4. And now enable it. {{< highlight bash >}} sudo pfctl -e {{< / highlight >}} ### 5. Configure sudoers to allow mitmproxy to access pfctl. Edit the file **/etc/sudoers** on your system as root. Add the following line to the end of the file: {{< highlight none >}} ALL ALL=NOPASSWD: /sbin/pfctl -s state {{< / highlight >}} Note that this allows any user on the system to run the command `/sbin/pfctl -s state` as root without a password. This only allows inspection of the state table, so should not be an undue security risk. If you're special feel free to tighten the restriction up to the user running mitmproxy. ### 6. Fire up mitmproxy. You probably want a command like this: {{< highlight bash >}} mitmproxy --mode transparent --showhost {{< / highlight >}} The `--mode transparent` flag turns on transparent mode, and the `--showhost` argument tells mitmproxy to use the value of the Host header for URL display. ### 7. Finally, configure your test device. Set the test device up to use the host on which mitmproxy is running as the default gateway and [install the mitmproxy certificate authority on the test device]({{< relref "concepts-certificates" >}}). {{% note %}} Note that the **rdr** rules in the pf.conf given above only apply to inbound traffic. **This means that they will NOT redirect traffic coming from the box running pf itself.** We can't distinguish between an outbound connection from a non-mitmproxy app, and an outbound connection from mitmproxy itself. If you want to intercept your own macOS traffic, see the work-around below or use an external host to run mitmproxy. In fact, PF is flexible to cater for a range of creative possibilities, like intercepting traffic emanating from VMs. See the **pf.conf** man page for more. {{% /note %}} ### Work-around to redirect traffic originating from the machine itself Follow the steps **1, 2** as above. In step **3** change the contents of the file **pf.conf** to {{< highlight none >}} #The ports to redirect to proxy redir_ports = "{http, https}" #The address the transparent proxy is listening on tproxy = "127.0.0.1 port 8080" #The user the transparent proxy is running as tproxy_user = "nobody" #The users whose connection must be redirected. # #This cannot involve the user which runs the #transparent proxy as that would cause an infinite loop. # #Here we redirect for all users which don't run transparent proxy. redir_users = "{ !=" $tproxy_user "}" #If you only wish to redirect traffic for particular users #you may also do: #redir_users = "{= john, = jane}" rdr pass proto tcp from any to any port $redir_ports -> $tproxy pass out route-to (lo0 127.0.0.1) proto tcp from any to any port $redir_ports user $redir_users {{< / highlight >}} Follow steps **4-6** above. This will redirect the packets from all users other than `nobody` on the machine to mitmproxy. To avoid circularity, run mitmproxy as the user `nobody`. Hence step **7** should look like: {{< highlight bash >}} sudo -u nobody mitmproxy --mode transparent --showhost {{< / highlight >}} ## "Full" transparent mode on Linux By default mitmproxy will use its own local IP address for its server-side connections. In case this isn't desired, the --spoof-source-address argument can be used to use the client's IP address for server-side connections. The following config is required for this mode to work: {{< highlight bash >}} CLIENT_NET=192.168.1.0/24 TABLE_ID=100 MARK=1 echo "$TABLE_ID mitmproxy" >> /etc/iproute2/rt_tables iptables -t mangle -A PREROUTING -d $CLIENT_NET -j MARK --set-mark $MARK iptables -t nat \ -A PREROUTING -p tcp -s $CLIENT_NET \ --match multiport --dports 80,443 -j \ REDIRECT --to-port 8080 ip rule add fwmark $MARK lookup $TABLE_ID ip route add local $CLIENT_NET dev lo table $TABLE_ID {{< / highlight >}} This mode does require root privileges though. There's a wrapper in the examples directory called 'mitmproxy_shim.c', which will enable you to use this mode with dropped privileges. It can be used as follows: {{< highlight bash >}} gcc examples/complex/full_transparency_shim.c -o mitmproxy_shim -lcap sudo chown root:root mitmproxy_shim sudo chmod u+s mitmproxy_shim ./mitmproxy_shim $(which mitmproxy) --mode transparent --set spoof-source-address {{< / highlight >}} |