LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-11-2013, 09:49 PM   #91
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 352

Original Poster
Rep: Reputation: Disabled

The device that I need to send to securely is the pic24 with no tcp/ip in it and limited amount of memory (256 bytes for this in ram). The computer it is connected to will of course have enough memory and tcp/ip so the communications between it and the website can use openSSL but I will have a java program on the other side of the pic which should send packets of encrypted data to the pic which in turn would decrypt the data and use a bootloader to store the program in flash. So I would need to know the format of the data sent as well as have the key in the pic24 so that the data could be decrypted. The program in the pic would need to be in C and I would need to know the algorithm to decrypt the program and that was what I was asking about.
 
Old 11-12-2013, 06:27 AM   #92
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
You don't seem to have enough memory for even TCP/IP in the PIC, much less enough to add encryption/decryption. 256 bytes is just not enough. TCP/IP alone would take around 4k (code + buffers).

The communication path between the PIC and whatever is not TCP/IP. It can't easily be protected at all if you only have 256 bytes. And since it has to be a dedicated line, you might not even need any. Between the computer it is connected to and the outside world is not a problem - software already exists for that (both with java options and native code). For even the simplest crypto (an xor) you need extra buffers - one for the encrypted data, one for the decrypted data - though you COULD try decrypting on the fly with xor, but that assumes a byte-by-byte xor, and the key still needs to be there - it would be embedded in the driver reading the interface. Anything else is limited to a stream cypher..(there are a number of them:http://en.wikipedia.org/wiki/Category:Stream_ciphers) but the size of the input data may be a problem (for an xor, the key should be at least as large as the message being sent).
 
1 members found this post helpful.
Old 11-12-2013, 11:18 PM   #93
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 352

Original Poster
Rep: Reputation: Disabled
The 256 bytes is what I have allocated for the buffer. The key would be type CONST and located in protected flash. the PIC24 is Harvard architecture with code in flash and ram for data. I probably will use a 128 byte key with the date as a random entry function. It will not, of course, be fool proof but just enough pain to keep most people in the dark. It will probably be XOR.

Still grinding away at the interpreter. Am working on get_exp (expressions). The arith routine is the largest since I have 4 data types for both the left and right sides of the binoral expressions. That is 16 case statements for each of the 27 operations for a total of 432 case statements. Using the compiler to figure out any conversions. Fourteen levels of precedence. Have = sign as a separate statement not part of the precedence. Functions are not part of the expressions. Not implementing +=, -=,etc but forcing the user to do that in his program. It is sort of BASIC with C expressions. I have 170k words of flash so hope it fits. About 3000 lines so far with some of tiny basic still in the code. They tiny basic skeleton was a life saver for me.
 
Old 11-13-2013, 01:37 AM   #94
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by schmitta View Post
The 256 bytes is what I have allocated for the buffer. The key would be type CONST and located in protected flash. the PIC24 is Harvard architecture with code in flash and ram for data. I probably will use a 128 byte key with the date as a random entry function. It will not, of course, be fool proof but just enough pain to keep most people in the dark. It will probably be XOR.
Ok. That would definitely make it possible. Especially when the middle system doesn't have the xor key.
Quote:
Still grinding away at the interpreter. Am working on get_exp (expressions). The arith routine is the largest since I have 4 data types for both the left and right sides of the binoral expressions. That is 16 case statements for each of the 27 operations for a total of 432 case statements. Using the compiler to figure out any conversions. Fourteen levels of precedence. Have = sign as a separate statement not part of the precedence. Functions are not part of the expressions. Not implementing +=, -=,etc but forcing the user to do that in his program. It is sort of BASIC with C expressions. I have 170k words of flash so hope it fits. About 3000 lines so far with some of tiny basic still in the code. They tiny basic skeleton was a life saver for me.
Thats why a translator save so much space - the decisions are made at compile time, not execution time for a specific sequence of code. Now there isn't much choice with a typeless language as the variables can change types, but for something more static, the analysis done at compile time makes it run faster, and with less code.

I have completed the interpreter (well, I am still thinking of adding a memory move operation, which would make copying buffers/chunks of data easier). Now getting documentation updated, adding information about the assembler.
 
Old 11-14-2013, 09:12 PM   #95
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 352

Original Poster
Rep: Reputation: Disabled
My weeks seem to be turning out as follows. Design on Monday. Write code Tuesday, Wednesday and Thursday and enter it on Friday. (I still write code by hand, a habit left over from the early 70's). This week has been harder because I am dealing with expressions, the arith routine and new problems with strings.
 
Old 11-15-2013, 04:03 AM   #96
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
I've been spending time similarly... though now I'm writing documentation which has required me to revisit code I wrote last year (the assembler and finding bugs that I should have seen and fixed then.

So, on Monday I started filling out docs explaining some code... and saw it not work for floating point... Tuesday, I realized the expression handling was at the root of one of the bug. So I completely rewrote it following a general grammar... Not too complex... Unfortunately, I had misorderd some return values and spent the next two days to find it. Fixed it. Dropped it into the assembler, and poof the bug was gone... and so was two others I hadn't realized yet. (I should have done that last year).

I now have a working example of a square root subroutine with a short main program for the stack machine, with configuration parameters (the resolution tolerance for Newtons approximation). It isn't the fastest - that calls for making a better guess - extract exponent of the number to take a square root of, divide by 2, use it for the exponent of the guess, then take the mantissa (between 0 and 1.0), and use a straight line intersect between 0 and .5 or between .5 and 1), then use that for the mantissa of the guess. Doing this means that the approximation only needs two or three iterations for the result instead of 7 to 9 (depending on the resolution tolerance).

It does mean I get to validate everything again - but that shouldn't take long (less than 10 minutes unless something goes wrong). The assembler now has a generic and flexible expression evaluator, and tracks type handling as well (fortunately, since it was in perl I didn't have to actually do the conversions - perl did it for me, but I did need to know how to handle the results as that depends on the type of data being output for the stack machine).

I'll be mailing you an update (it will be bigger given the test cases and validation references, plus some documentation (hopefully by Monday), and a good bit of bug fixes in the stack machine). I'm still thinking about adding a block data move instruction, but that isn't that complicated to do.
 
1 members found this post helpful.
Old 11-19-2013, 04:44 AM   #97
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 352

Original Poster
Rep: Reputation: Disabled
Grinding through arith routine (432 cases) which is part of get_exp (expressions). Used #define macros with parameters for the first time to reduce coding and increase entry accuracy. Only have unary to do. Then it is the precedence levels routines.

Last edited by schmitta; 11-19-2013 at 04:47 AM.
 
Old 11-19-2013, 05:05 AM   #98
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Added more documentation on the assembler, fixed another old bug.. And realized I forgot
the integer/float conversion... added that and test functions.

Just sent you the update.

Insomnia just seem to get things done, doesn't it.

Last edited by jpollard; 11-19-2013 at 05:06 AM.
 
Old 11-19-2013, 08:27 AM   #99
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 352

Original Poster
Rep: Reputation: Disabled
I hope you don't have insomnia. I was talking about my work days. I had a good nap yesterday so I only slept 3 or 4 hours last night and was up when you sent the files. Was doing some research on image processing on the VA Tech library website. Bought a book on it that uses JAVA 2D from amazon for $2 plus $3.99 shipping.

Last edited by schmitta; 11-19-2013 at 08:34 AM.
 
Old 11-19-2013, 02:59 PM   #100
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
It comes and goes.

Usually, I sleep til 5 AM (the cats tend to wake me starting around then), sometimes I do wake at 2-3AM, and work on various things, read... then tend the cats (13 at the moment, 3 geriatric, so they need some extra handling, and a just spayed kitten). I can usually go back to sleep around 9AM.

It helps being retired, so I don't have specific times that I'm required to be awake.
 
Old 11-19-2013, 08:00 PM   #101
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 352

Original Poster
Rep: Reputation: Disabled
Lots of CATS! Must keep you busy. Hope you are enjoying retirement. I am retired on $806 a month! That is why I am doing the interpreter. When do you go to bed(!?)
 
Old 11-19-2013, 08:54 PM   #102
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
It varies. 9PM sometimes. I've always petered out about 10 though (well, there was a period in my youth when I only needed 3 hours a night - lasted about a year). Ever since being an adult I've liked to get 3-4 hour sleeps twice a day, some days more (been known to occasionally do 12 hours).

Early career was navigation systems (loranC/GPS/high resolution microwave), so odd hours were expected, with occasional 80+ hour weeks. But I was still single then. We made several operating systems based on PDP-8s, PDP-11s. 11/23 (up to 4MB on the later versions, my favorite CPU architecture). Lots of threaded code interpreters on the smaller
systems. PDP-8s had a software floating point, but implemented as mode change that made it look like it had hardware floating point. The smaller PDP-11s (11/05 specifically) had vendor provided floating point software with single and double precision. We needed faster speed, but only 1.5 precision (16 bit words, so our modified software used 6 bytes for floating point instead of 8 - and it saved memory too). Access to it was again through an interpreter (a stack machine no less).

Most of my career has been as a system admin, so late hours were nothing unusual. For a while, I had a 2 hour overlap for management, while the rest was like a 2AM arrival, configure systems, get the network operational, get everything setup and running by monday. But once operational things stabilized.

Covered a visualization lab, development systems, and management. Then moved into supercomputer management for various companies (contractors all). Ended up developing center management tools (consolidated console with logging for 3 supercomputers+about 10 service systems, KDC, DNS/Mail/network router, and a distributed user account management. For a couple of years we could get a user activated on any authorized systems within an hour. Came up north to work for NRL on Kerberos maintenance. Laid off in a budget crunch, then retired.
 
Old 11-19-2013, 11:17 PM   #103
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 352

Original Poster
Rep: Reputation: Disabled
Sounds like a hard life. Lots of cats. Hope retirement is good to you.
 
Old 11-20-2013, 04:41 AM   #104
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
getting used to it. The cats are not that difficult (other than the elderly ones). I really don't like having to put them down.

But we have been lucky so far - our seniors are over 16 now, with the eldest 17 (or older - we don't know how old she was when we got her. Only that she had kittens 2 years before).
 
Old 11-23-2013, 07:56 AM   #105
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 352

Original Poster
Rep: Reputation: Disabled
Still working on get_exp (expressions). The guy before me used recursive calls to higher and higher level routines to achieve expression operator precedence. I have about 14 levels of precedence with a lot of parameters for the calls (4 data types) so that would have eaten up a lot of stack space. Found some good information on the web to go from infix to postfix expressions so part of this week was given to writing those routines. That part turned out to be fun. Found out that I actually had 5 data types with the new one being a bit returned for logical (==,!=,>,<,>=,<=) operations. Had to modify the language's bnf slightly to simplify finding the end of an expression. Quit on Friday to work on my lawnmower. It would not start and found the flywheel was slightly out of line but am having trouble getting the flywheel puller to bite into its screw holes. Once the flywheel is off I can re position it and put in another flywheel key to correct the timing so that it will hopefully run right.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expressions nova49 Linux - Newbie 4 07-13-2011 07:05 AM
Regular Expressions Wim Sturkenboom Programming 10 11-19-2009 01:21 AM
regular expressions. stomach Linux - Software 1 02-10-2006 06:41 AM
Regular Expressions overbored Linux - Software 3 06-24-2004 02:34 PM
help with REGULAR EXPRESSIONS ner Linux - General 23 10-31-2003 11:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration