21 January 2013

Do NOT touch crypto code.

No, I'm not coding any crypto algorithms. Even following discussions about coding them, like gnutls, nettle, and openssl mailing lists, is hard. But just to demonstrate the complexity of coding crypto algorithms, think of side-channel attacks. I quote here from a mailing list on nettle:


Let me first explain what I mean when I talk about a "side-channel
silent" function. That means that if we call the function with operands
which are of the same size, but otherwise different, the function should
execute exactly the same sequence of instructions in both cases, and
access memory in exactly the same pattern.

If one then assumes that the underlying machine instructions have data
independent timing (true for most current cpus), we leak no side
information from timing or cache behaviour. We may still leak
information through power analysis, if, e.g., executing a multiplication
instructions consumes different amount of energy depending on the input
bit patterns.

-- Niels Möller

What does that mean? It means "Do NOT touch crypto code". Unless you understand the implications. And there are too many implications in too many aspects, that laymen like you and me do not understand. I mean, can you even imagine that your code could be susceptible to power analysis? I mean, yes, in algorithms you've been taught that a multiplication is "costlier" than addition, and if you've studied transistors and digital logic and algorithm analysis, you might begin to understand why, because more transistors are needed for multiplication (I'm guessing here), but to think that that cost involves differences in power usage! Well of course, but then to think that that difference in power usage could be used to analyse the number of multiplications used by your code, and hence begin to backtrack the input of your functions! Yeowza. So hey, lesson of the day: "Do NOT touch crypto code".

16 January 2013

OpenSSL, cURL, and multithreading.

OpenSSL is one of the most widely used crypto library. Supports many digest and cipher algorithms, many types of protocols, very light and extremely optimized for many platforms (take a look at the arm assembly or x86_64 assembly codes for different algorithms.. gives you a sense of the awesome work put into it by experienced people through the years), and yet, out of the box, it is not thread-safe.

Couple of points to note here:
- This does not mean that OpenSSL cannot be used in a thread-safe way. It can be, but a little work has to be put in.
- Related links: http://horstr.blogspot.in/2008/04/on-libcurl-openssl-and-thread-safety.html,
http://curl.haxx.se/libcurl/c/threaded-ssl.html, http://stackoverflow.com/questions/3281373/segmentation-fault-in-libcurl-multithreaded.
- cURL is a URL handler, like wget, and it fetches the contents of urls. For HTTPS connections, you can make curl use either OpenSSL, or GnuTLS, or other supported implementations of SSL. OpenSSL is default.
- When using curl in multi mode, you can create several easy handlers (like one for each url), and attach them  to a single multihandle, so as to give commands to the multi handle which it internally performs on each of the urls. Since OpenSSL is not threadsafe by default, this multi handle usage of curl can cause rare random crashes.
- To avoid all these, OpenSSL provides callback mechanism to set your own locking functions (like simple pthread mutexes, or your own mutexes/locks if you prefer). This will enable multiple parallel initializations and cleanups without causing a hitch.

Now the question arises, who sets these callback functions? Curl certainly doesn't set it, and shouldn't, in my opinion as it should remain light, portable, and shouldn't define its own constraints. The final app can always set its own callbacks. Imagine, then, if multiple apps are running as threads in a single process... like maybe in a browser/platform or something... If each of the apps set their own callbacks, there is the possibility that these locks are not mutually interoperable. So shouldn't the browser/platform set its own callbacks? Should they or shouldn't they be overrideable by the apps' callbacks? ugh. I've never liked mutexes and semaphores. too messy :(

1 June 2012

Post-post

Like the new look? No? Tough luck. I do. And here're the reasons why:

- It's a mosaic! Who doesn't love a tiling pattern?
- It's monochrome and bleak looking. Suits my emo mood.
- Fragments of broken thoughts, barfed all over the space. My thoughts, exactly.
- My fuggin blog, my fuggin wish!

27 February 2012

Just realized..



Octennial, Novennial, Decennial - 8th, 9th and 10th year adjectives.
Octal, Nonal, Decimal - base 8, 9 and 10 number systems.
Octagon, Nonagon, Decagon - 8, 9 and 10 sided polygons.


October, November, December - 10th, 11th and 12th months.
AARRGGGHHHH!!!!!!

Frikkin Ceasar and his calendar. His salads are nice, though.

Also, following after decade, decagon, and decennial, I propose that December should be pronounced Dick-ember.


(Also just realized: the song would then go like "This is my dick-ember ...")

1 February 2012

"Delhi taught me confidence!"

.. is such a paradoxical statement. For once one comes to live in Delhi, one realizes that there is no such a thing as "teaching" confidence. On a regular morning at the breakfast table one might even startlingly realize, that one either has confidence, or one doesn't. One might even come to find that said confidence somewhere around the corner, and simply pick it up, but confidence - one learns - can just not be taught. No predefined rules can be found, nor axioms be defined, which uniformly decide the levels of confidence of a person.

In other news, I would like to present to you a very peculiar idea, which seems to me to be on par with the only ever innovations in the fabric industry:
- the zipper, and
- the buttonhole.
Now kiss (In other words, why not mix the two?)! I present to you, the Zipton (c). Imagine, if you can*, two ends of cloth so adjacent to each other as to facilitate the usage of either the zipper or the button flap, or both!

ʘ_ʘ

The mind boggles!


*If you can indeed imagine such an arrangement, please do approach me. I have a business proposition for you.

19 December 2011

And it Happened...

So. I think I remember the night now. The night I cried for the fate of the Telugu Language, the night I came to know about the concept of dubbing, and the night that forever changed my perspective of Telugu movies. I'm willing to bet the movie was one of the classics of those eras, either Gharshana or Maro Charitra or some such like, and I distinctlyremember this, crying to my little self at that time, "but I am only 5 years old!'' And here's why.

We were returning from seeing the movie at the town theatre, and were going back to our village. In a tonga, mind you, because autorickshaws hadn't yet hit the scene by then. I AM that old. It was me, my mother, my aunt her sister, and probably my brother and two or all three of my cousins. And the discussion had turned to how well the dubbing was done, or instead how well the other movie had been dubbed! and so on. Intrigued that they were talking about the same movie that I had just seen, and not understanding what exactly, I asked innocently what dubbing was. And I was explained at that age, how movies were dubbed, remade, and essentially copy pasted onto another Language. My simple mind couldn't have understood then, but what I suspect I found aghast, at even that tender age, was the idea that Languages and Cultures weren't one-to-one in the aspect (relation) of influence they have on each other. I couldn't comprehend. Why would we need to steal ideas from other cultures or languages? Couldn't we make our own Telugu movies so well? What could we be lacking in, that would lead us to consider other languages greater than our own? I was outraged. I wept. I wept for Telugu, the Language and the Culture both, the latter as especially manifested in movies.

I wept at the shredding of my innocence, and cried out mentally to the powers that be, ``but I'm only 5!'' Why would you do such a thing to me, universe? I wept so hard that I was relegated to sit beside the driver, as I was making too much of a racket inside the cab. Which is why that thought stuck to me, and even at 5 yrs, I was well made aware of my ingenue in matters concerning others than bats and balls. Which could probably also have contributed to my aversion towards all things concerning physical sports, but that is another story and I digress.

Putting that in perspective, I hope one can well understand why I have had a healthy distrust in both Telugu and Telugu movies until the age of 18, when I left home for the first time. Things have changed now, and I am a strong believer again in Telugu (both movies and the language), but that transformation has not come about overnight, nor easily. I have only come to understand later, the idea that a language's love is like a mother's love, nourishing and nurturing. Ironically after leaving home and motherland (AP). Or maybe not as ironic as all that, seeing as we all miss our moms only after leaving our homes.

And I have realized all this only now, when I am 27 years old, and tripping through old memories. Trying to make some sense of myself and my apparent contradictions. Yes, I do appreciate even dubbed movies now, only because I realize now that Languages and Cultures can never remain one-to-one, Geography permitting. Human indeed is a social animal, and the dubbing of movies from various mother tongues to hindi or vice versa*, is but as symbolic in emotion as a friendly neighbour saying "Good Day!". To quote Donne clichedly,

"No man is an island, entire of itself; every man is a piece of the Continent, a part of the main. If a clod be washed away by the Sea, Europe is the less, as well as if a Promontory were, as well as a manor of thy friends or of thine own were; any mans death diminishes me, because I am involved in Mankind. And therefore never send to know for whom the bell tolls; it tolls for thee.''


Geography willing, no man or language or culture can remain an island, entire of itself. (Examples of untouched unexplored virgin native cultures come to mind, because they have remained resident in unexplored and remote islands). And so I come to understand that yet another facet of myself, that I had heretofore considered contradictory, was not really one. As I have a love/hate relationship with the language, so do I with the movies. The case remains though, of my love for English (both, language and movies), and what kind of a relationship I have with Hindi.





*Yes, I do not still consider Hindi a proper mother tongue. Hindi tongue seems to me to be but an amalgamation of so many different bols and urdu. Representative as may be of the people, as much a republic State is of all the states that reside in it.
**Some parts above are fictitious. :D

15 May 2009

Of Opportunities, wasted and wanted.

It's surprising, sometimes, how much one can learn in a span of a few minutes, from someone whom one has spent listening to for the most part of three years. I know this is true of most of my friends here who've spent time with Prof. Ranil N. Biswas, (especially the ones that gave him a farewell party tonight) that they are proud to have known such a distinguished personality, and regret that they might not ever meet him again.

Those who have known Prof. RNB, or was a student under him, need no introduction (By the way, this also includes the director of my current Institute, Dr. Rajeev Sangal). For those unfortunate few who have not known him, he is one of the few 'old world' teachers left. 'Old world' not in the sense of physical age, because I can dare say he is fitter than most of my friends, but 'old world' in the sense of the kind of vision, commitment, dedication, and satisfaction achieved from a work well done, or a life well lead, that is present only in the people of the previous generation. He has spent more than 40 years teaching, of which more than 30 years were spent at IIT-K, has served as the Director of IIT-K, and this is only his teaching career.

Here are excerpts from an informal gathering we had. These quotes are not verbatim, but they convey the meaning.

I haven't told this to many people, but one of the things I feel really proud about, is not my 4.0 CGPA at Berkeley, but the fact that I could show them an Indian could do it. An Indian is 'no worse' than them.
I had to do a course from the Physics department, to fill my credits. This was taught by a Nobel Laureate in Physics, to the brightest students in physics, and I had to hold my own against them.
One of my moments of crowning glory, was this: The Nobel Laureate was a panelist in my thesis review panel, and when I went to him to get my thesis reviewed, he said "You are from the Electrical Department? But you stood second in my class! And the one who stood first was from the Physics Department!" He was surprised to believe someone from outside the Physics Department could do so well.
One of the things I cherish the most, is that my students remember me even after some 30 odd years. Even now, whenever I meet some of them, they arrange get-togethers, much like you did. That is something that will always give me pleasure.
I had never ever thought I would end up in teaching one day. I was even convinced that would be the last of my career options.
One cannot 'learn' teaching. Teaching is like acting. Either you can do it, or you can't. One has to have an aptitude to do such things. That is why I always say, if you really want to do something well, you need to first really like doing it.

The only reason I took up a PhD was that was the only way I got to see America in those days.
Who else had the funding?


He is one of those very few people who know how to do a thing well, and are content in the knowledge that they have done their best to do it well. When asked why he didn't pursue 'research', he said that he had made his choice long back. "There were very few people who wanted to improve the quality of the teaching, or the teaching material, or the course structure and such things. I thought I could do it, and went ahead and did it."

He has a zest for life. He has been to most of the developed countries, loves to blaze away in fast cars (his top speed was 100 mph, which he achieved both in the US and in India), loves to play sports (he still plays table tennis), and still maintains working hours that rival the best of workaholics.

Like I said, it is surprising how much one can learn from just one night spent with such a man, when one had all the opportunity to do it for four long years. With a mixed sense of awe, respect, gratitude, and humility, I say thank you, sir, for giving us this opportunity.