SyZero and crypto #38

Fermé
ouvert(e) par devnexen 2018-08-08 11:11:55 +02:00 · 9 commentaires
Membre

More a question actually ... it is used as well to clear the MD5 context.
Would be interesting to know if SyZero can be possibly optimised by aggressive optimisation by the compiler thus not guarantying it. In other hash algo implementations before memset was used but then SecureZero* or explicit_bzero replaced these.
That is something I did myself for php, I implemented explicit_bzero for musl for the next release for this kind of purpose too.

More a question actually ... it is used as well to clear the MD5 context. Would be interesting to know if SyZero can be possibly optimised by aggressive optimisation by the compiler thus not guarantying it. In other hash algo implementations before memset was used but then SecureZero* or explicit_bzero replaced these. That is something I did myself for php, I implemented explicit_bzero for musl for the next release for this kind of purpose too.
devnexen a ajouté le label question 2018-08-08 11:12:52 +02:00.
Auteur
Membre

In fact SecureZero* functions from Win32 API and explicit_bzero/explicit_memset (NetBSD flavor if I recall) had been created to guarantee the address is gueninely cleared regardless of the code consumer compiler optimisation used(basically either adding a memory barrier like musl or a particular compiler settings different from the rest of the libc like openbsd does for example ...).
Do not know if I am clear enough though :-)

In fact SecureZero* functions from Win32 API and explicit_bzero/explicit_memset (NetBSD flavor if I recall) had been created to guarantee the address is gueninely cleared regardless of the code consumer compiler optimisation used(basically either adding a memory barrier like musl or a particular compiler settings different from the rest of the libc like openbsd does for example ...). Do not know if I am clear enough though :-)
Auteur
Membre

Ah the question is SyZero able to guarantee to clear the context regardless of the optimisation ? :-)

Ah the question is SyZero able to guarantee to clear the context regardless of the optimisation ? :-)
Propriétaire

When I look at PH7 as overall and the amount of bugs as well as Symisc Systems approach, I doubt it can guarantee anything. :)
For example SyStringInitFromBuf() simply takes the char* and int and stores into a structure. The string can be of any length, and any length can be specifies. However, the length is not checked anywhere and I already several times came across SyString showing some trash after the requested string. Symisc resolved that by adding %z to their string formating functions. But if you want to convert SyString to char*, you should be careful.

When I look at PH7 as overall and the amount of bugs as well as Symisc Systems approach, I doubt it can guarantee anything. :) For example SyStringInitFromBuf() simply takes the char* and int and stores into a structure. The string can be of any length, and any length can be specifies. However, the length is not checked anywhere and I already several times came across SyString showing some trash after the requested string. Symisc resolved that by adding %z to their string formating functions. But if you want to convert SyString to char*, you should be careful.
Auteur
Membre

Ok ... something to keep in mind even though not the highest priority at the moment.

Ok ... something to keep in mind even though not the highest priority at the moment.
devnexen a été assigné par belliash 2018-08-09 15:21:30 +02:00.
Auteur
Membre

Found odd too first time I read it unless it is to avoid some compiler optimisations ?

Found odd too first time I read it unless it is to avoid some compiler optimisations ?
Propriétaire

No idea, but its not first time I see something like that in PH7. There are more of them. In this particular case, the whole loop could be even replaced by:

memset(zSrc, 0, zEnd - zSrc);
No idea, but its not first time I see something like that in PH7. There are more of them. In this particular case, the whole loop could be even replaced by: memset(zSrc, 0, zEnd - zSrc);
Propriétaire

I have contacted with Symisc. They told me, that's an old manual optimisation technique targeting Intel CPUs and was inspired from the qmail source tree. Basically if you unloop your code and duplicate it four times, you can get non insignificant speed boost on some old x86 architecture. They also told me, they didnt want to use memset, as they wanted a minimal dependency with libc.

Nova days, I think we can rely on compiler optimisations.

I have contacted with Symisc. They told me, that's an old manual optimisation technique targeting Intel CPUs and was inspired from the qmail source tree. Basically if you unloop your code and duplicate it four times, you can get non insignificant speed boost on some old x86 architecture. They also told me, they didnt want to use memset, as they wanted a minimal dependency with libc. Nova days, I think we can rely on compiler optimisations.
Propriétaire

To sum up, I think SyZero is currently able to guarantee to clear the context regardless of the optimisation. @devnexen: Do we need anything else, or can we close this ticket?

To sum up, I think SyZero is currently able to guarantee to clear the context regardless of the optimisation. @devnexen: Do we need anything else, or can we close this ticket?
Auteur
Membre

Nothing to add.

Nothing to add.
devnexen a fermé ce ticket 2018-08-18 21:07:05 +02:00.
Connectez-vous pour rejoindre cette conversation.
2 participants
Notifications
Échéance
Aucune échéance n'a été définie.
Dépendances

Aucune dépendance définie.

Référence : aerscript/Aer#38