<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://bitpost.com/w/index.php?action=history&amp;feed=atom&amp;title=Security</id>
	<title>Security - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://bitpost.com/w/index.php?action=history&amp;feed=atom&amp;title=Security"/>
	<link rel="alternate" type="text/html" href="https://bitpost.com/w/index.php?title=Security&amp;action=history"/>
	<updated>2026-04-19T05:35:55Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://bitpost.com/w/index.php?title=Security&amp;diff=4682&amp;oldid=prev</id>
		<title>M: Created page with &quot;=== KERBEROS HANDSHAKING ===      CLIENT AUTHENTICATION     Client &gt; username &gt; AS (which is running the TGS)     client &lt; [Client/TGS session key] (encrypted with user pw) &lt;...&quot;</title>
		<link rel="alternate" type="text/html" href="https://bitpost.com/w/index.php?title=Security&amp;diff=4682&amp;oldid=prev"/>
		<updated>2018-04-09T13:54:43Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;=== KERBEROS HANDSHAKING ===      CLIENT AUTHENTICATION     Client &amp;gt; username &amp;gt; AS (which is running the TGS)     client &amp;lt; [Client/TGS session key] (encrypted with user pw) &amp;lt;...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=== KERBEROS HANDSHAKING ===&lt;br /&gt;
&lt;br /&gt;
    CLIENT AUTHENTICATION&lt;br /&gt;
    Client &amp;gt; username &amp;gt; AS (which is running the TGS)&lt;br /&gt;
    client &amp;lt; [Client/TGS session key] (encrypted with user pw) &amp;lt; AS/TGS&lt;br /&gt;
    client &amp;lt; TGT (client info encrypted with TGS secret key, can&amp;#039;t be decrypted by client) &amp;lt; AS/TGS&lt;br /&gt;
    client decrypts [Client/TGS Session Key] for communication with TGS&lt;br /&gt;
&lt;br /&gt;
    CLIENT SERVICE AUTHORIZATION&lt;br /&gt;
    client &amp;gt; TGT, Service Principal Name (SPN, aka hostname) &amp;gt; TGS&lt;br /&gt;
    client &amp;gt; Authenticator (clientid+timestamp, encrypted with client/TGS key) &amp;gt; TGS&lt;br /&gt;
    client &amp;lt; Client-to-server ticket, encrypted with service&amp;#039;s key &amp;lt; TGS&lt;br /&gt;
    client &amp;lt; Client/Server Session key, encrypted with Client/TGS Session Key&lt;br /&gt;
&lt;br /&gt;
    CLIENT SERVICE REQUEST&lt;br /&gt;
    client &amp;gt; client-to-server ticket &amp;gt; Service Server (SS)&lt;br /&gt;
    client &amp;gt; new Authenticator &amp;gt; SS&lt;br /&gt;
    client &amp;lt; timestamp confirmation &amp;lt; SS&lt;br /&gt;
    client confirms&lt;br /&gt;
    client &amp;gt; service requests &amp;gt; SS&lt;br /&gt;
    client &amp;lt; service responses &amp;lt; SS&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== OVERVIEW ===&lt;br /&gt;
&lt;br /&gt;
Notes to review before interviews, etc:&lt;br /&gt;
&lt;br /&gt;
    ---------------------------&lt;br /&gt;
    fedramp cloud certification&lt;br /&gt;
    ---------------------------&lt;br /&gt;
      strong encryption, eg AES 256-bit&lt;br /&gt;
      data should be encrypted before it leaves end-user &amp;quot;organization&amp;quot;&lt;br /&gt;
      encrypt: data-at-rest, data-in-transit, data-in-use&lt;br /&gt;
      encryption keys MUST be kept within end-user org&lt;br /&gt;
      CSP requirements: implement security, third-party assess, maintain authorization, comply with continous monitoring&lt;br /&gt;
      &lt;br /&gt;
  basics review&lt;br /&gt;
 &lt;br /&gt;
      public-private key&lt;br /&gt;
      ------------------&lt;br /&gt;
      plain -&amp;gt; encrypted -&amp;gt; plain&lt;br /&gt;
            ^            ^&lt;br /&gt;
          publickey      privatekey&lt;br /&gt;
          &lt;br /&gt;
      &lt;br /&gt;
      SSL HANDSHAKE&lt;br /&gt;
      -------------&lt;br /&gt;
      client                                                    server&lt;br /&gt;
             -&amp;gt; hello -&amp;gt;        &lt;br /&gt;
             &amp;lt; cert&lt;br /&gt;
      (check) &lt;br /&gt;
               send secret encryped with server public key &amp;gt;    decrypt secret)&lt;br /&gt;
               (opt) send client cert &amp;gt;                         (check - but not otherwise used?)&lt;br /&gt;
               ack&amp;gt;&lt;br /&gt;
               &amp;lt;ack&lt;br /&gt;
               exchange with shared secret key&lt;br /&gt;
 &lt;br /&gt;
  best encryption to date&lt;br /&gt;
    ssl labs: &lt;br /&gt;
      Key RSA 2048 bits (e 65537)&lt;br /&gt;
      signature SHA256withRSA&lt;br /&gt;
      certchain includes Let&amp;#039;s Encrypt Authority X3, RSA 2048 bits, Signature: SHA256withRSA&lt;br /&gt;
      TLS 1.2 (not allowed: TLS 1.1, 1.0; SSL 3, SSL 2&lt;br /&gt;
        TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (0xc02f)  ECDH secp256r1 (eq. 3072 bits RSA)   FS 128&lt;br /&gt;
        TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 (0xc027)  ECDH secp256r1 (eq. 3072 bits RSA)   FS 128&lt;br /&gt;
        TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA (0xc013)     ECDH secp256r1 (eq. 3072 bits RSA)   FS 128&lt;br /&gt;
        TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 (0x9e)      DH 2048 bits   FS 128&lt;br /&gt;
        TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 (0x67)      DH 2048 bits   FS 128&lt;br /&gt;
        TLS_DHE_RSA_WITH_AES_128_CBC_SHA (0x33)         DH 2048 bits   FS      &lt;br /&gt;
    &lt;br /&gt;
    review &lt;br /&gt;
 &lt;br /&gt;
      AES 256-bit for encryption&lt;br /&gt;
        aka Rijndael, which won in the original NIST AES selection process (in 2001!)&lt;br /&gt;
        symmetric key algorithm (same key to encrypt and decrypt)&lt;br /&gt;
        block size 128&lt;br /&gt;
        key length 256 (can be 128 and 192)&lt;br /&gt;
 &lt;br /&gt;
      SHA-256 for signatures&lt;br /&gt;
        a bit-specific SHA-2&lt;br /&gt;
        deprecates SHA-1&lt;br /&gt;
        NOT deprecated by SHA-3 (an alternative developed through NIST competition)&lt;br /&gt;
        256-bit &amp;quot;hash values&amp;quot; aka digests aka signatures)&lt;br /&gt;
        server + client ssl certificate process&lt;br /&gt;
        &lt;br /&gt;
      HMAC is a signature with a key - what I&amp;#039;m doing with JWT (HMAC-SHA256)&lt;br /&gt;
        &lt;br /&gt;
     broken: RC2 RC4 DES IDEA ...&lt;br /&gt;
 &lt;br /&gt;
     next-gen: https://security.stackexchange.com/questions/135054/whats-after-aes&lt;br /&gt;
      TLS 1.3, which is still a draft, is going with two authenticated ciphers as its required choices:&lt;br /&gt;
        AES-GCM, with either 128- or 256-bit keys;&lt;br /&gt;
        ChaCha20/Poly1305&lt;br /&gt;
      The reasons we have two are the following:&lt;br /&gt;
        As a backup—if one of them is broken, everybody can switch to the other;&lt;br /&gt;
        They have different strengths:&lt;br /&gt;
        AES-GCM has excellent hardware support in many platforms;&lt;br /&gt;
        ChaCha20/Poly1305 has faster all-software implementations than AES-GCM does.&lt;br /&gt;
 &lt;br /&gt;
    good for https with SSL certs, according to SSL labs:&lt;br /&gt;
        TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (0xc02f)  ECDH secp256r1 (eq. 3072 bits RSA)   FS 128&lt;br /&gt;
        TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 (0xc027)  ECDH secp256r1 (eq. 3072 bits RSA)   FS 128&lt;br /&gt;
        TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA (0xc013)     ECDH secp256r1 (eq. 3072 bits RSA)   FS 128&lt;br /&gt;
        TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 (0x9e)      DH 2048 bits   FS 128&lt;br /&gt;
        TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 (0x67)      DH 2048 bits   FS 128&lt;br /&gt;
        TLS_DHE_RSA_WITH_AES_128_CBC_SHA (0x33)         DH 2048 bits   FS      &lt;br /&gt;
   &lt;br /&gt;
 &lt;br /&gt;
  NIST (National Institute of Standards and Technology)&lt;br /&gt;
  &lt;br /&gt;
    SHA-3 competition 2007-2012 (SHA = Secure Hash Algorithm)&lt;br /&gt;
      64 entries&lt;br /&gt;
      5 finalists: BLAKE, Grøstl, JH, Keccak and Skein&lt;br /&gt;
      winner: Keccak&lt;br /&gt;
      schneier&amp;#039;s feedback:&lt;br /&gt;
        Yes, I would have rather my own Skein had won, but it was a good choice.&lt;br /&gt;
 &lt;br /&gt;
  NSA has Suite A (classified algorithms that will not be released) and Suite B cryptography algorithms&lt;br /&gt;
    Suite B&amp;#039;s components are:&lt;br /&gt;
    &lt;br /&gt;
    Advanced Encryption Standard (AES) with key sizes of 128 and 256 bits. &lt;br /&gt;
      For traffic flow, AES should be used with either &lt;br /&gt;
        the Counter Mode (CTR) for low bandwidth traffic or &lt;br /&gt;
        the Galois/Counter Mode (GCM) mode of operation for high bandwidth traffic (THIS CAN BE PARALLELIZED)&lt;br /&gt;
    Elliptic Curve Digital Signature Algorithm (ECDSA) – digital signatures&lt;br /&gt;
    Elliptic Curve Diffie–Hellman (ECDH) – key agreement&lt;br /&gt;
    Secure Hash Algorithm 2 (SHA-256 and SHA-384) – message digest&lt;br /&gt;
 &lt;br /&gt;
  talk about my projects&lt;br /&gt;
 &lt;br /&gt;
    nopc&lt;br /&gt;
      energy market&lt;br /&gt;
      need to measure power behind the consumers meter&lt;br /&gt;
      i wrote a client that lives on embedded devices&lt;br /&gt;
      i cross-compiled openssl, libmodbus, libcurl, libwebsockets, zlib&lt;br /&gt;
 &lt;br /&gt;
      ssl / websockets work:&lt;br /&gt;
        libwebsockets uses openssl, but i have played a bit with optional ssl: wolfssl&lt;br /&gt;
          has streaming media support, including the HC-128 and RABBIT stream ciphers&lt;br /&gt;
          Standard ciphers are supported, including EDH on both the client and server side.  &lt;br /&gt;
          wolfSSL recently added support for BLAKE2b, one of the SHA-3 finalists as well. &lt;br /&gt;
          wolfSSL’s underlying cryptography library is called wolfCrypt.&lt;br /&gt;
        i wouldn&amp;#039;t want to stray from openssl unless there was a more compelling reason, since it gets so many eyeballs on it&lt;br /&gt;
        people don&amp;#039;t like its depth of support for other algorithms, just stick with best-in-class&lt;br /&gt;
          Key RSA 2048 bits (e 65537)&lt;br /&gt;
          signature SHA256withRSA&lt;br /&gt;
          pki: rsa&lt;br /&gt;
&lt;br /&gt;
      given a guid token, it uses that to generate ssl certs on the device&lt;br /&gt;
      then it runs 24/7 on the embedded device&lt;br /&gt;
      it has a tight loop with callbacks, C is gross but you can do pretty much anything&lt;br /&gt;
        in factthats the problem, you have to do everything!&lt;br /&gt;
        again, i heavily rely on reusable helpers&lt;br /&gt;
      so it has a single-threaded loop with callbacks&lt;br /&gt;
      poll:&lt;br /&gt;
        if !config configure client&lt;br /&gt;
        else poll and store meter data, buffered to memory then volatile then nonvolatile storage&lt;br /&gt;
        if ws not connected initiate connection&lt;br /&gt;
        service the connection callbacks (sending bi-directionally as needed)&lt;br /&gt;
 &lt;br /&gt;
    just added jwt to abettertrader&lt;br /&gt;
      uses HMAC-SHA256 (uses a secret during signature generation)&lt;br /&gt;
      client sends u/p&lt;br /&gt;
      server builds header+payload+HMAC-SHA256 signature with its own secret&lt;br /&gt;
      server sends back base64-encoded token to client&lt;br /&gt;
      client uses token on every API call&lt;br /&gt;
      when token times out, user must log in again&lt;br /&gt;
      server can almost instantly determine user&amp;#039;s priviledges without a db hit&lt;br /&gt;
      that&amp;#039;s why they call it stateless&lt;br /&gt;
 &lt;br /&gt;
    abettertrader c++ based webserver, gets A+ rating at ssllabs&lt;br /&gt;
    via haproxy!&lt;br /&gt;
      I serve up several domains from my home&lt;br /&gt;
      most of them use SNI with apache&lt;br /&gt;
        with SNI the hostname is sent outside of the encrypted traffic&lt;br /&gt;
        so you can serve up different apache sites based on the requested hostname&lt;br /&gt;
        it&amp;#039;s fantastic - for years i had to serve up my different sites on different ports&lt;br /&gt;
        and it was hard to do https that way&lt;br /&gt;
      but! ... i&amp;#039;m running a C++ https server as well&lt;br /&gt;
      and i had to solve the problem of getting incoming https traffic to that server running on that port&lt;br /&gt;
      haproxy is THE BOMB for these kinds of things&lt;br /&gt;
      i configured haproxy to read the domain name and redirect traffic to the c++ http server and port&lt;br /&gt;
      but i am so excited about this, i got these bonuses with zero effort:&lt;br /&gt;
        ALL ssl handshaking is now done by haproxy!  i just give it ALL my certs, and it does the negotiations&lt;br /&gt;
          i was able to limit availabe ciphers to those listed as secure at ssllabs&lt;br /&gt;
            ssl-default-bind-options no-sslv3 no-tls-tickets force-tlsv12&lt;br /&gt;
            ssl-default-bind-ciphers AES128+EECDH:AES128+EDH&lt;br /&gt;
        ALSO i was able to turn on HSTS - this forces all http requests into https requests&lt;br /&gt;
          and that got me an A+ rating on ssllabs - for ALL My sites - in one fell swoop!&lt;br /&gt;
          i felt like that giant that killed 7 flies or whatever&lt;br /&gt;
      &lt;br /&gt;
    abettertrader uses a map of lambas and regexs&lt;br /&gt;
      when a url comes in, it plays it against all the registered regexs&lt;br /&gt;
      if it finds a match, it calls the lambda&lt;br /&gt;
      it&amp;#039;s really fast and really fun&lt;br /&gt;
      &lt;br /&gt;
    i set up node.js scripting for my continuous integration&lt;br /&gt;
      i have an open source package called radscripts - it does an automatic semver bump on every commit&lt;br /&gt;
      i&amp;#039;m totally addicted to that&lt;br /&gt;
      you can turn it off and still get all the benefits - &lt;br /&gt;
      i turned off auto-tagging at causam because they wanted to control the specific numbers of releases&lt;br /&gt;
      but semver dictates: ...&lt;br /&gt;
      &lt;br /&gt;
    i am always tinkering, i keep track of my projects in phabricator, an agile ticket tool that sprang out of facebook          &lt;br /&gt;
      do you want to see it?&lt;br /&gt;
      willcodeforcoffee.org moodboom/G&lt;br /&gt;
 &lt;br /&gt;
  write a c++ app that sorts an array then encrypts it then decrypts it&lt;br /&gt;
    int main() {&lt;br /&gt;
      return 0;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
  review c++11, c++14, interview questions&lt;br /&gt;
    RAII resource acquisition is initializaztion- constructor acquires, destructor releases&lt;br /&gt;
 &lt;br /&gt;
  c++ &lt;br /&gt;
    c++11 features I love:&lt;br /&gt;
      automatic type detection - this is great esp for iterators so you don&amp;#039;t have to type as much&lt;br /&gt;
      for loops&lt;br /&gt;
        if you don&amp;#039;t need to walk forwards or backwards as you loop, these greatly simplify code profile&lt;br /&gt;
        but if you need the iterator as you loop, you can stick with the old way&lt;br /&gt;
      lambda expressions - really fast to write inline functions&lt;br /&gt;
      move semantics - you don&amp;#039;t have to copy out results when you&amp;#039;re done in a function, you can move them - and it&amp;#039;s largely automatic, really nice&lt;br /&gt;
      initialization syntax - i love this for creating test data, you can easily initialize big arrays, whatever, right in code&lt;br /&gt;
      delegating constructors - this si great, so you don&amp;#039;t have to rewrite all the base class constructors to be able to add a new one&lt;br /&gt;
      threading - a lot of this is available with boost - but it&amp;#039;s nice to have the standard incorporate all the best boost work&lt;br /&gt;
    c++14 seems much more incremental than 11 was&lt;br /&gt;
      you can use auto for function return types - that was already how lambdas worked in c++11, i thought...&lt;br /&gt;
      lamdba parameters can be auto - kind of like templating, seems really crazy and cool - haven&amp;#039;t played with this much yet&lt;br /&gt;
      and closures, how cool is that!!!  &amp;quot;lambda captures&amp;quot;  it carries along the scope from where it was called.  &lt;br /&gt;
        javascript of course makes us a huge fan of this.&lt;br /&gt;
        but i wonder about the performance penalty involved. - again, haven&amp;#039;t played with it much&lt;br /&gt;
        deprecated keyword, binary literals&lt;br /&gt;
    and then c++17 is on the way - c++ has always made me happy, i find it incredibly elegant compared to lower C or higher java/C# arenas&lt;br /&gt;
      i think javascript actually hits a sweeter spot than those&lt;br /&gt;
      so i&amp;#039;m enjoying C++ and javascript more than anything these days&lt;br /&gt;
      i wrote some utilities in node so i can use node for scripting, which has been really productive&lt;br /&gt;
      but i have to say, python would be a welcome addition&lt;br /&gt;
 &lt;br /&gt;
  c++ containers&lt;br /&gt;
    &lt;br /&gt;
    i use hashmaps of pointers via unordered_map&lt;br /&gt;
    unordered set lets you contain pointers, and specify the hash and equals values for the object pointed to&lt;br /&gt;
    typedef std::unordered_set&amp;lt;AutotradeParameterSet*,PersistentIDObject_hash,PersistentIDObjects_equal &amp;gt; AutotradeParameterSets;&lt;br /&gt;
    then you can set up a second &amp;quot;index&amp;quot; into the object store&lt;br /&gt;
    you have to maintain all indexes as you add and remove, of course&lt;br /&gt;
    &lt;br /&gt;
    unordered_map uses the hash to find the right bucket O(1)&lt;br /&gt;
    map uses a binary tree and a comparison operator O(log(n))&lt;br /&gt;
    std::find() on vector uses quicksort O(N*log(n)) or insertsort which uses heapsort for worst case&lt;br /&gt;
      mergesort is good to preserve order of equal items (in-place)&lt;br /&gt;
    &lt;br /&gt;
    python has TimSort, pretty cool - looks for presorted sections, then merges those, COOL&lt;br /&gt;
      in use in python since about 2002&lt;br /&gt;
    &lt;br /&gt;
    i also use a sorted vector class i derived from the standard vector class&lt;br /&gt;
      it too can use pointers instead of objects, allowing for multiple indexes on a set of objects&lt;br /&gt;
      it has push_unsorted(), bSorted() and sort(sort_function) functions&lt;br /&gt;
      usually with vectors you use lower_bound to find things&lt;br /&gt;
      sorted vector has find helpers, and they always sort if unsorted&lt;br /&gt;
      it&amp;#039;s really useful when you have a huge amount of objects and only sort on occasion&lt;br /&gt;
 &lt;br /&gt;
  - nagging question: how do you add functionality to a product that&amp;#039;s new?  &lt;br /&gt;
      this was a very valuable question that I didn&amp;#039;t answer well&lt;br /&gt;
      can i ammend my answer?&lt;br /&gt;
        i mentioned that I would diagram function flows - that would definitely be a key strategy&lt;br /&gt;
        and to read any and all available documentation on the software&lt;br /&gt;
      what should have also been part of my answer: &lt;br /&gt;
        generate my own documentation as needed&lt;br /&gt;
        a fantastic tool for that is doxygen&lt;br /&gt;
        i ran it yesterday against a recent project, and it did a nice job creating class hierarchies etc.&lt;br /&gt;
  &lt;br /&gt;
      clang-tidy is suggested to be the best on reddit&lt;br /&gt;
        even has a -fix flag to fix in place, ha&lt;br /&gt;
        cmake can call it for you!!&lt;br /&gt;
      cppcheck&lt;br /&gt;
      coverity for Paid solutions&lt;br /&gt;
 &lt;br /&gt;
      jsonlint&lt;/div&gt;</summary>
		<author><name>M</name></author>
	</entry>
</feed>