Welcome

Pacific Simplicity is the home to my tech blog of sorts, aiming to assist and provide information easily to other Linux users and Open Source hackers out there.  It contains articles on Linux, system admin hints, scripting, programming embedded systems, OpenWRT and of course Drupal . Check it out and don't forget to comment!

Posted: Sun, 12/07/2014 - 16:42

Quick simple (and probably not entirely correct) definitions:

  • Prime - a prime number is a number which cannot be divided by any other numbers except itself or 1
  • Modulo - in computation, it means that it returns the remainder of a number when it is divided by another
  • Natural number - any negative or positive whole number
  • Real number - in layman's terms, when you don't have a whole number
  • Set - a group of numbers which could be generated by a generator for example
  • Generator - every number is a generator; generates a group or set of integers

Main concepts

  • Cannot divide numbers (otherwise a real number could result)
  • Instead of dividing, a number can be inverted and multiplied
  • Every number has an inverse
  • Groups - are a set of integers, a set of mathematical operations and some rules which these numbers abide by
  • A safe prime is a number where p is a prime and is the result of q (another prime) times 2 + 1 (p = 2q + 1)
  • Order - Order of an element g (generator) is the smallest t such that g to the power of t = 1 mod p. In other words the values until 1 for that generator.

If we want to get the Order of all g's mod p (where p = 11), it will be one of { 1, 2, 5, 10 }

  1. p - 1 = 10 (if p is 11)
  2. 10 = 1 *10
  3. 10 = 2 * 5
  4. 10 = 10 * 1
  5. 10 = 5 * 2

Generate the below two tables for mod p using these programs (where p is a prime, is 11 and is also Safe).

  1. ./mult 11
  2.       1   2   3   4   5   6   7   8   9  10
  3.   1   1   2   3   4   5   6   7   8   9  10
  4.   2   2   4   6   8  10   1   3   5   7   9
  5.   3   3   6   9   1   4   7  10   2   5   8
  6.   4   4   8   1   5   9   2   6  10   3   7
  7.   5   5  10   4   9   3   8   2   7   1   6
  8.   6   6   1   7   2   8   3   9   4  10   5
  9.   7   7   3  10   6   2   9   5   1   8   4
  10.   8   8   5   2  10   7   4   1   9   6   3
  11.   9   9   7   5   3   1  10   8   6   4   2
  12.  10  10   9   8   7   6   5   4   3   2   1
  13.  
  14. ./exp 11
  15.       0   1   2   3   4   5   6   7   8   9  10
  16.   1   1   1   1   1   1   1   1   1   1   1   1
  17.   2   1   2   4   8   5  10   9   7   3   6   1
  18.   3   1   3   9   5   4   1   3   9   5   4   1
  19.   4   1   4   5   9   3   1   4   5   9   3   1
  20.   5   1   5   3   4   9   1   5   3   4   9   1
  21.   6   1   6   3   7   9  10   5   8   4   2   1
  22.   7   1   7   5   2   3  10   4   6   9   8   1
  23.   8   1   8   9   6   4  10   3   2   5   7   1
  24.   9   1   9   4   3   5   1   9   4   3   5   1
  25.  10   1  10   1  10   1  10   1  10   1  10   1

Okay, every number is a generator which generates a group of integers. Generation means taking a number (g) and raising it to a power.

Posted: Thu, 12/04/2014 - 17:04

Here are two simple C programs which generate the multiplication and exponentiation tables for modulus p

Exponentiation program

Posted: Sat, 11/08/2014 - 08:49

One of the interesting things that I recently discovered was that the serial interface or at least the GPIO pins that would provide a serial console is NOT as straight forward as it should be (I mean really? Serial is somewhere around retirement age if electronics could age as humans).

I have learned that only thinking about a problem will not solve it; so I started digging into it by verifying that my brand new Raspberry Pi B+ was actually working. Here were my troubleshooting steps:

  • I installed a new clean image of Rasbian onto a brand new and working mini-SD card; I even verified the hash sums using sha1sum
  • Plugged it into my TV using HDMI & added a USB mouse/keyboard combo - it booted and worked

For the next few hours I hunted around the internet for reasons as to why it is not working; there are hundreds of posts stating no serial port or do this and that. However, before hunting around into the depths of configuration - I still need to verify two things:

  • The pins are actually working (I learned this in my brief stint in IT; check the cabling stupid)
  • Verify that the USB to TTL adapter is actually working (still unknown at this moment)

To verify the GPIO pins, I scouted through my hardware box and grabbed the following:

  • 3 female to male wires
  • 2 LEDs of different color
  • 2 330Ohm resistors
Posted: Fri, 10/31/2014 - 13:09

For awhile, I have wanted to write a simple tutorial of in-line patching of binaries and in particular, changing the assembly instructions and having a binary skip to whatever function we desire manually. This involves tweaking the callq instruction (call can be altered too, but it refers to a static address vs. a relative address).

Okay so lets get started - this tutorial is written to alter one specific thing and assumes that you have some basic knowledge of assembly & know how to compile basic programs. I am also assuming that you could find strings within binaries and know how to convert values in hexadecimal.

The example to be used in this test application contains a main function, and two functions (function1 and function2) which print different messages. The goal of this exercise is to modify the application AFTER it has been compiled so that function2() is executed instead of function1().

Posted: Fri, 10/24/2014 - 10:27

Assuming that you are like me and needed to jury rig something together to read a serial port on a Lannar 6020B industrial PC. Here is what I did

Step one, access the boards documentation and determine the pin-out diagram for the COM port.

Remove the board's shroud/case and find the serial/COM port on the board.