A Security Device


The purpose of this assignment is to get you to use Finite Automata concepts in solving real-life problems.

Think of simulating a security installation very similar to those installed in many offices and homes. The installation has a keypad and an engine (a controller) used to decide whether the user has entered the correct access code or not.

The keypad has ten keys, labeled from '0' to '9'. The security engine will unlock the lock when it finds the correct un-locking access code in the input string. Likewise, the security engine will lock the lock when it finds the correct locking access code in the input string.

For example, let's assume that the un-locking code is 33441. If the user enters the string 91352033441245, then the lock will be unlocked as soon as the engine finds the last correct letter of the access code in the input string. The engine will lock the lock again when the user enters the locking code. Assuming that the locking code is 33444 then the lock will be locked and unlocked as described below:

913520334412451033444123970001112334451334410101
  unlock--^         ^--lock        unlock--^

Your program will read from standard input without echoing the input characters. Characters other than digits 0 throuh 9 will be quietly discarded. Your engine will recognize a fixed access code. The access code will be the first four digits of your Social Security Number, followed by a 1 for the unlock code and by a 4 for the locking code.

DDDD1 is the unlocking code
DDDD4 is the locking code, where DDDD are the first four digits of your SSN

As soon as the last didgit of the access code is entered, your program will signal the action taken (lock or unlock).

Let's now assume that a possible intruder does not have any idea about how long the access string is. You decide to test how long it takes for one to unlock the lock. One possible way to try to break the lock is to generate a random sequence of numerical digits as the input string to the device. Of course, after each digit input from the keypad the intruder should check to see whether the lock has been unlocked or not. This would naturally increase the time it takes an intruder to break your security mechanism.

  • Try to estimate how long it would take (on the average) to break the lock if one has to wait one second to see if the lock has unlocked or not. Assume the random number generator has an uniform distribution.
  • Do the actual test: use some random number generator to generate the input string for the security device. Count how many symbols (digits from 0 to 9) have been generated before the lock is unlocked. Ignore the waiting time in this case and have the program run at full speed. Since you use random numbers you will have to repet the test several times to obtain significant results; find the minimum, maximum and the average.

What you'll turn in

  1. A well commented listing of your program (C or C++ is recommended but not required). Note that grading, as described below, considers both the functionality and the readability of your code. You must follow the coding style and documentation standards used in the Computer Science and Applied Mathematics Department.
  2. A floppy disk (3.5") which contains the source file(s) for your program, a DOS executable named lock and a README file indicating what the program does, how to build the executable, the platform it's been tested on, and how to run it, plus any other information you consider useful - like the name of the author, etc.
  3. A memo describing what you have done, how you have done it, and your findings. In the memo clearly state what is the language of the FA you have implemented. Also indicate what is the regular expression corresponding to that language. There will be two attachments to the memo:
    1. a context free grammar that generates the same language
    2. the state transition diagram for the FA.

    Direct the memo to your class instructor.

  4. You don't need to be concerned about optimization(s). In particular you are not required to minimize the number of states in your FAs. You can do so if you want but this is not a must.

Grading

  1. A mark between 0 and 10 for functionality. The mark basically indicates in what measure your program works properly and how well you have followed the initial specification.
  2. A mark between 0 and 10 for readability. This mark indicates how well documented your program is; it also considers the general appearance of your final report.
  3. Multiply the above two marks to get the mark for this programming assignment.

For each business day you turn in your project earlier you receive a 5% bonus. However, penalties increase by 5% as well. You can turn in your assignment up to ten business days ahead of the deadline.
Example:

  • You turn in your assignment three days earlier: a 3*5=15% bonus will be added to your assignment mark
  • We find a single mistake in the functionality section and the penalty for that mistake is 0.5 points. Since you have turned the assignment three days earlier than the deadline, the penalty becomes 0.5*(1+3*5%)=0.5*(1+3*0.05)=0.575
  • We calculate the mark by multiplying the marks for the functionality and readability; in your case the mark for functionality is 10-0.575=9.425, and the mark for readability is 10. The result is 9.425*10=94.25
  • We add the bonus to this mark: 94.25+94.25*15%=108.38 which we round to 108. This is your final mark.

You may be asked to do a code review with your instructor.


(c) 1997, Virgil Bistriceanu Last update: April 1, 1998 The cs330 home page