The software has its live cycle during which the development and bug fixing are link to several variables, some under control or the developer but many are out of this control. I'm not talking much about the time dedicated to the development during a project, but too. Those variables are out of control specially in the bug fixing time, when the speed and extreme programming are more present.
When some day, some how, some one decides that something is urgent, or more urgent than the other urgent things. At that time, the development will done because of an heroic effort and all bugs will be fixed fast (hopping that the bug fix will not produce any other side effect).
How old must be a code to consider refactoring? It could depend on the number of requirements coming from the heaven. I mean when the number of times that some one is very urgent to codify, the developer does it, but with a price. And this price is a quality loss, until it becomes untenable. When any bug fix requires longer and longer time due to the side effects of the modification.
But there is a moment, that triggers an alert for the project manager that says refactoring is mandatory: when the design have almost nothing in common with the code: when code smell.
Then I found a book that looks nice for this task: "Refactoring: Improving the Design of Existing Code" Fowler, Martin (1999). More than ten years old book, older than the code I want to refactor, live irony.
2012/08/08
2012/08/06
Generalized Rijndael, schematics
Before to enter in deep on the questions remarked in the previous post about this series, I like to post some schemas that some day would be useful.
The Rijndael symmetric cryptosystem build by iteration using a network of permutations who follows the basic shannon's properties of "confusion and diffusion". The bits in the plain text are mixes and substituted by a group of operations do by an order. To decrypt, what have to be done is to do the same things but in the opposite way. For sure, there is a key to introduce here the secret to be able to undo the encrypt operation.
As in the diagram 1 shows, using only 4 operations (subBytes, shitfRows, mixcolumns, addRoundKey, and its inverses). But those operations are in a certain order to maintain a set of properties.
Is necessary to emphasize the use of a part of the key in the 'addRoundKey()' operation. This round key is much longer than the given key to encrypt/decrypt, and the process to generate this key expansion can be described in a iterative way:
The first 4x4 matrix (the
) is the original key given with in a structure of a matrix of elements in the wordsize (8 bits, a byte in rijndael, AES). This example is using the 128 key option but the key matrix can have more columns: To build the key expansion its the same way, but remark that "#c" represents the number of columns for the message, not the key.
To build the following columns to have each round keys, an iterator is good to see how this is made. I have tried to get an schema from other webs sites, but the ones that I found haven't convinced to me. I hope this would help to someone who search on internet for a diagram of the rijndael key expansion.
The Rijndael symmetric cryptosystem build by iteration using a network of permutations who follows the basic shannon's properties of "confusion and diffusion". The bits in the plain text are mixes and substituted by a group of operations do by an order. To decrypt, what have to be done is to do the same things but in the opposite way. For sure, there is a key to introduce here the secret to be able to undo the encrypt operation.
![]() |
| Diagram 1: Flow of the Rindael encrypt/decrypt |
As in the diagram 1 shows, using only 4 operations (subBytes, shitfRows, mixcolumns, addRoundKey, and its inverses). But those operations are in a certain order to maintain a set of properties.
- subBytes: word substitution, where each element in the state matrix is replaced by its inverse and an affine mapping. Operations in
- shiftRows: cyclic left shift of the elements of the i'th row by i words.
- mixColumns: column linear transformation of the state matrix, where each column is given as an element of a polynomial ring, where the coefficients of this polynomial are polynomials in
.
This polynomial ring is: - addRoundKey: XORed transformation between the state matrix and the round key.
Is necessary to emphasize the use of a part of the key in the 'addRoundKey()' operation. This round key is much longer than the given key to encrypt/decrypt, and the process to generate this key expansion can be described in a iterative way:
![]() |
| Diagram 2: Iterator schema of the Rijndael key expansion |
To build the following columns to have each round keys, an iterator is good to see how this is made. I have tried to get an schema from other webs sites, but the ones that I found haven't convinced to me. I hope this would help to someone who search on internet for a diagram of the rijndael key expansion.
2012/08/02
RFC 6637 and construct elliptic curves
A new request for comments is available for elliptic curve cryptography. With the number 6637 the past June 11th was announced as official. Very good news for the elliptic curves and its cryptographic implementations.
From the first version of this standard when it was a candidate has passed a few months more than 4 years. Yes, more than 4 years to public discussion. Necessary for consensus in standard development, but much more necessary for cryptography.
The old project of the patch for GnuPG, who was already obsolete a long a go, have some relation with the final code in the GnuPG. I'm glad when I see it in the sources that I have contributed somehow.
But what about the supported curves? The mentioned standard restricts the use of only a very few of them. The supported curves are only 3, one per each supported size: from the fips 186-3 the p-256, p-384 and p-521 (the biggest 3 of the 5 in the Appendix D.1.2 "Curves over Prime Fields). They are known as the NIST curves and they are from the NSA suite b.
Yes, the standard doesn't close completely the use of other curves. There is a field in the structure of the key to specify the curve, but is not set directly the curve. What is place in the field is the curve OID. Even if the number of curves that can be listed using this Object Identifiers can be very big, it will never be as big as the existing and cryptographically valid elliptic curves. But there is hope in this issue, it wasn't like that the full time of this pre-standard process, there is a octet, the first one, who have a reserved value (0xFF) for future extensions.
Why can be so important to use as many curves as the users want? Easy, one of the biggest features in elliptic curves is the possibility to change the cyclic group where the discrete logarithm is protecting your secrets, without changing the size is because using a different curve with in the same base finite field the hardness of move an attack from the cyclic group in one curve to another cyclic group in another will be almost equivalent to start from scratch the attack over the new cyclic group on the new curve over the same finite field.
But, how can be a new curve generated? Recently in arxiv I've seen a article about this matter: "Method for constructing elliptic curves using complex multiplication and its optimizations" (July 30, 2012).
I've been working in isogenies using volcanoes and stars of them to speed up the initial way to construct a new curve (pointed in the abstract of the cited article):
From the first version of this standard when it was a candidate has passed a few months more than 4 years. Yes, more than 4 years to public discussion. Necessary for consensus in standard development, but much more necessary for cryptography.
The old project of the patch for GnuPG, who was already obsolete a long a go, have some relation with the final code in the GnuPG. I'm glad when I see it in the sources that I have contributed somehow.
But what about the supported curves? The mentioned standard restricts the use of only a very few of them. The supported curves are only 3, one per each supported size: from the fips 186-3 the p-256, p-384 and p-521 (the biggest 3 of the 5 in the Appendix D.1.2 "Curves over Prime Fields). They are known as the NIST curves and they are from the NSA suite b.
Yes, the standard doesn't close completely the use of other curves. There is a field in the structure of the key to specify the curve, but is not set directly the curve. What is place in the field is the curve OID. Even if the number of curves that can be listed using this Object Identifiers can be very big, it will never be as big as the existing and cryptographically valid elliptic curves. But there is hope in this issue, it wasn't like that the full time of this pre-standard process, there is a octet, the first one, who have a reserved value (0xFF) for future extensions.
Why can be so important to use as many curves as the users want? Easy, one of the biggest features in elliptic curves is the possibility to change the cyclic group where the discrete logarithm is protecting your secrets, without changing the size is because using a different curve with in the same base finite field the hardness of move an attack from the cyclic group in one curve to another cyclic group in another will be almost equivalent to start from scratch the attack over the new cyclic group on the new curve over the same finite field.
But, how can be a new curve generated? Recently in arxiv I've seen a article about this matter: "Method for constructing elliptic curves using complex multiplication and its optimizations" (July 30, 2012).
But this article proposes the other way around, start finding an order that satisfy the conditions and then build a curve of this order. It's a promising idea to have a nice way to have as many curves as necessary.
With the isogenies, I didn't found how to speed this up enough to have a new (cryptographically good) curve during the key generation (a reasonable time to not desperate the user). And even more, having the possibility to reset your key by change and old curve by a new one with out needing to create a new key, but assuring the security by a public and auditable procedure.
With the isogenies, I didn't found how to speed this up enough to have a new (cryptographically good) curve during the key generation (a reasonable time to not desperate the user). And even more, having the possibility to reset your key by change and old curve by a new one with out needing to create a new key, but assuring the security by a public and auditable procedure.
What is the utility of this feature of the cryptosystem reset? One that I can imagine, and can be compatible with the current standard is to have a corporative elliptic curve in the smart cards and periodically renew the curve. Knowing the path in the isogeny star, all the smart cards would be able to "migrate", but for a cryptoanalyser will be a very enormous hard work to "port" any running attack, even if the public keys are available in both curves, from the origin to the current if the path is still secret.
The most important thing in cryptology is the trust on mathematics. Giving the user 3 curves, that looks good, but only 3, is not enough. Like the S-boxes in DES, that wakes up susceptibilities, specially at the beginning, to know how they had been build (why those and not any other). Even more, giving a list of hundreds of thousands curves is neither enough because the problem is still the same.
The unique solution I see on that issue, is to give this public and auditable algorithm that allows the community to validate (or break) it that make the user confortable with the provided security.
Generalized Rijndael, a review
After a too long period of time with out working on this project I like to recover it.
I did a python implementation, that will be publish as free software (GPL) who is able to change the usual parameters of the Rijndael to work in a very different way than the 3 options of the standard. As a review:
Rijndael variable parameters:
But what means internally to the algorithm this change?
Are there other options in Rijndael to get this combination? Yes: this would be equivalent to {40,4,4,2,16} and what does this mean?
I did a python implementation, that will be publish as free software (GPL) who is able to change the usual parameters of the Rijndael to work in a very different way than the 3 options of the standard. As a review:
Rijndael variable parameters:
- Number of rounds
- Number of rows
- Number of columns
- Wordsize (in bits)
- Number of columns in the key
- Block size always 4x4 elements of 8 bits
128 bits
- Key size can have 4, 6 or 8 columns
128,192,256 bits
- And depending on this key size the number of rounds varies from 10, 12 or 14.
But what means internally to the algorithm this change?
- A new irreducible polynomial is need for the mixColumn() transformation, because the polynomial ring
have the same number of coefficients than the number of rows.
Are there other options in Rijndael to get this combination? Yes: this would be equivalent to {40,4,4,2,16} and what does this mean?
- A new Rijndael SBox must be build: the original is made to apply a substitution of works of 8 bits.
Pending demonstrations:
- Is the generalized Rijndael still a Pseudo-Random Permutation (PRP)
- How to build secure SBoxes?
- How to get irreducible polynomials to be able to change the number of rows?
- How to calculate the number of rounds necessary? Not less than need to be insecure, but not more to do superfluous calculations.
2012/07/13
When politicians creates a hole in the bottom of the bag
Yesterday, there where an announcement in the Spanish parliament about the biggest cuts ever seen in this country. And what was the reaction of our representatives? 50 seconds of applauses... Very very sad to see "my" representatives applauding the president because of the hardest blow up to now.
Are we in a representative democracy? The current government have won election with promises that the firsts month start to be invalidated. Just after they won, the budget publication was delayed until regional elections.
Those politicians are not serious! There is not left and right anymore.
What about the recent announcement:
Are we in a representative democracy? The current government have won election with promises that the firsts month start to be invalidated. Just after they won, the budget publication was delayed until regional elections.
Those politicians are not serious! There is not left and right anymore.
What about the recent announcement:
- Increase the VAT from 18% to 21% (reduced VAT 8% to 10%), and probably move products from reduced to normal (this means from 8% to 21% in one step).
- Reduce the salary of the public workers about the 7% (masked saying that is cutting the extra payment of Christmas). Usually the annual gross salary is divided in 14 payments, even if we call it extra, they are part of the salary.
- Reduce the number of local representatives on villages, towns and cities.
- Reduce the unemployment payment after 6 months without a job.
And from the ones who have a job, there is a field in the salary where is subtracted each month some money for an unemployment, insurance like, bag. And in case that I lost my job, I can get this and the number and time depends on how much I have placed there.
Well it work this way:
- You put some part of your salary in a bag. And the time you can have this insurance unemployment payment depends of how much you have placed in.
- There is a top of the bag. After you reach this top you contribute to the common. That means: you continue paying the insurance but you will not give anything more back.
- and now, in the middle of the game, some one decide that what you thought you had in the bag will be less in case you need.
But the problems are still there, and will not be fixed with this measures. Even more, this will made them worst:
- Unemployed will have less to circulate money, and not really contribute to find a job that doesn't exist.
- Employed will not circulate money because we don't know for how long we will have this job. Sooner or later, will we lose the job and confirm the theory?
Some of my doubts:
- Where is this country going?
- What can we have by pacific protest in the squares? (15M like)
- Are the politicians, and the ones who move the threads from the shadow, aware about the increase of the hate to them by the respectable citizens?
- Are they aware that punishing the pacific protest like terrorism or authority resistance, is the way to justify violent protests? (price by price...)
Next Saturday: "(...) faced a major economic crisis (...) and exacerbated by a regressive system of taxation (...)"
2012/06/26
When solutions are the answer to different problems
With in this Spanish crisis, many problems have been identified. The main issue are the possible solutions. Every day in the news the citizens are informed about new creative solutions to that problems. The issue of those solutions is that too often they are solutions for other problems or only partial solutions for the announced problem.
Last one is the Spanish health care system. From the last years many times have mentioned that the level of the retirement system is too high, unsustainable. The country can not support that level and the age of retirement was extended and the conditions worsen. It looks like only the public retirement systems was affected and nothing mention about private retirement plans.
Following the same path, the medicine prescriptions from the public health care are now, again, in the target point. Again the terms and conditions "changes during the game" with only one side agreement.
Ok, in Catalunya the citizens will pay extra fee for a prescripted medicine, and also the pensioners who had their medicines for free will have to pay for them. Also Spanish government have its own plan to increase the fee in medicines according to the incomings. Abstractly it looks good, it looks to have solidarity principle. But not in this country.
But what about the very old issue of the containers of the medicines? Long a go have said and now forget, that the containers of the medicines wasn't adapted to the treatments. Very loud have said that this mismatch costs a lot of money to the public resources. Even that the solution is to increase the part that the citizens pay directly by the use instead of fix the problem of the sizing of the medicine boxes.
Well done. This problem is not fix because the implemented solution doesn't fix completely the problem and it's only a temporally patch. Typical Spanish.
Furthermore, because this new fee depending on the incomings request to cross data from treasure department and the health care department a new fraud comes to the surface: an enormous fraud using sanitary cards. That's not new, it was already from long a go in the list of usual frauds in health care. Well they simply quantify it.
But all the citizens will suffer the consequences of this fraud? Isn't this solution worst for the ones who did it correctly? And again, this is a partial patch, it doesn't fix the problem.
A few day a go, another economical announcement from the government: "The with VAT or without it, must finish". The government will fight the black economy when a few weeks a go they promote a tax amnesty.
Day by day we see this, once again and again. Big adds with very big solutions, and after a few days they are forget or implemented in a way that didn't fix the initial problem.
We rescue the banking when the government is not acting to get save the citizens. The system of the mortgages it's dark. In capitalism there are wins and losts of the bets. We know the banks have carried a risk giving loans, but now we can see that in practice they only win.
When the things goes wrong they receive public money to refloat. Public money that created public debt. Due to that the citizens saw how the rules changes during the game (retirement, taxes,...) but the banks law cannot change to avoid a perverse system where the bank move you out of your home, you loose it, and you still have a debt with this bank (who can be bigger that the initial) and if need the bank is rescued.
Last one is the Spanish health care system. From the last years many times have mentioned that the level of the retirement system is too high, unsustainable. The country can not support that level and the age of retirement was extended and the conditions worsen. It looks like only the public retirement systems was affected and nothing mention about private retirement plans.
Following the same path, the medicine prescriptions from the public health care are now, again, in the target point. Again the terms and conditions "changes during the game" with only one side agreement.
Ok, in Catalunya the citizens will pay extra fee for a prescripted medicine, and also the pensioners who had their medicines for free will have to pay for them. Also Spanish government have its own plan to increase the fee in medicines according to the incomings. Abstractly it looks good, it looks to have solidarity principle. But not in this country.
But what about the very old issue of the containers of the medicines? Long a go have said and now forget, that the containers of the medicines wasn't adapted to the treatments. Very loud have said that this mismatch costs a lot of money to the public resources. Even that the solution is to increase the part that the citizens pay directly by the use instead of fix the problem of the sizing of the medicine boxes.
Well done. This problem is not fix because the implemented solution doesn't fix completely the problem and it's only a temporally patch. Typical Spanish.
Furthermore, because this new fee depending on the incomings request to cross data from treasure department and the health care department a new fraud comes to the surface: an enormous fraud using sanitary cards. That's not new, it was already from long a go in the list of usual frauds in health care. Well they simply quantify it.
But all the citizens will suffer the consequences of this fraud? Isn't this solution worst for the ones who did it correctly? And again, this is a partial patch, it doesn't fix the problem.
A few day a go, another economical announcement from the government: "The with VAT or without it, must finish". The government will fight the black economy when a few weeks a go they promote a tax amnesty.
Day by day we see this, once again and again. Big adds with very big solutions, and after a few days they are forget or implemented in a way that didn't fix the initial problem.
We rescue the banking when the government is not acting to get save the citizens. The system of the mortgages it's dark. In capitalism there are wins and losts of the bets. We know the banks have carried a risk giving loans, but now we can see that in practice they only win.
When the things goes wrong they receive public money to refloat. Public money that created public debt. Due to that the citizens saw how the rules changes during the game (retirement, taxes,...) but the banks law cannot change to avoid a perverse system where the bank move you out of your home, you loose it, and you still have a debt with this bank (who can be bigger that the initial) and if need the bank is rescued.
2012/06/19
On the passing years
Even if the politicians have inaugurate this facility in 2008, it's now when this resource can be used. If I remember correctly, when this has been inaugurated we have been doing the booster commissioning, the installation of the storage ring wasn't completed and don't imagine who the beamlines was.
But today, we have started receiving the first friendly users. In this case, a very similar thing happen. In the news is indistinguishable if they are friendly users (that means we are in the last part of the commissioning) or if they are the users that have applied to the user office call for proposals.
But we have a synchrotron!
Uou! There is a detail on this picture. We have the letters of the synchrotron name painted in the roof of the warehouse. This warehouse is a building in side the are of the synchrotron but the machine and the beamlines are in the circular building in the centre of the image.
Can we see this letters closer?
What the hell! This letters are uncoloured, but they has been painted in 2010 (just when the salaries of the workers has been cutted) and repainted in February 2011.
Why do we have 4 big letters in the roof of a secondary building of this facility?
Can this be only to distinguish the building in google maps?
In a country like españistan everything it is possible. Cut salaries, when paint superfluous letters in a roof.
Subscribe to:
Posts (Atom)


