« first day (3141 days earlier)      last day (1831 days later) » 

09:50
Huh, where did that one-way function candidate question go? Did the user delete it?
 
3 hours later…
12:54
0
Q: Permutation of first $k$ prime powers as a one-way function?

TrevorLet $a_1$ through $a_k$ be some permutation of the first $k$ primes. Let $n \in [1,k!]$ be a parameter specifying the exact ordering by taking the $n$th permutation in a sorted list or by some other simple mechanism. Then define $f(n,k)=a_1^{p_1}+a_2^{p_2}+\ldots+a_k^{p_k}$, where $p_i$ is the $...

@Maeher This is deleted one. It was a copy of the Math version.
 
3 hours later…
15:33
From SO: "Hexutil.java is the file where all the magic is happening "
 
1 hour later…
16:56
Where did I miss that?
0
Q: Trying to recreate the working java encryption method in nodejs

rahul.sharmaI have a working Java code for encryption of string in AES encryption using the key , and i have been trying the replicate the code in Nodejs for quite long but unable to get the exact encrypted hash output as Java code gives me. Please let me know what i have been doing wrong. Encrypt.java ...

how terrible is it to use javascript with hex values?
You stopped that sentence too late: "how terrible is it to use javascript" is just fine.
well, I just cannot image what modulo addition would look like in javascript
Another question why sha256(key, data) didn't match the expected HMAC output. Can you guess that one?
17:00
442
A: Why is Math.random() not designed to be cryptographically secure?

Eric LippertI was one of the implementers of JScript and on the ECMA committee in the mid to late 1990s, so I can provide some historical perspective here. The JavaScript Math.random() function is designed to return a floating point value between 0 and 1. It is widely known (or at least should be) that t...

Not a confession but explain the something behind the curtain.
Browsers also may run on various systems. If you would run /dev/urandom on some old Debian and even Ubuntu machines you could easily hang the entire system by depleting the entropy pool. Actually, I'm wondering if you still cannot.
So it may be frickin' weird, but using a non-secure random would be more secure in that situation. World is weird.
@bdegnan The sha256 function didn't implement HMAC at all, but JS simply ignores spurious arguments.
oh, wow
JavaScript cannot be used to produce secure code, because it injects uncertainty at every step. C has a lot in common, but it doesn't fail at that kind of level.
more complexity -> less security. More state -> less security.
More uncertainty -> more possible state.
Cryptography is probably strange in the way that it introduces complexity and security :)
Well, considered that 90% of posts on SO shows insecure code, I might as well say that it may introduce security.
Hey @fgrieu :)
Your assertions imply that more Javascipt -> less security, which is obviously correct. Hence your assertions must be true :-)
17:17
Locating falacy....
The Correlation/Causation Fallacy
Got it.
Long live webassemply and the languages written on top of it.
ply?
(reattaches "b" key the right way up)
I'm rather fond of C, but I'm generally pretty intimate with hardware. I'm mindful of buffers and such. Most of what I write C for, I also wrote the HDL or made the IC.
I want to learn Python for matplotlib, but the white space kills me. :/
Yeah, I get C for lower platforms. But even then, I'd rather use a low level language where at least some bounds checking is performed for most functionality. I've seen too many horrid mistakes and doing "software security" course on Coursera kindof cemented my opinion.
Writing an entire OS in C with millions upon millions lines of code ... what could possibly go wrong?
17:48
@bdegnan Question: do you regularly use things like valgrind (or any other source code analysis) on your code? Or is that too complex for embedded platforms?
I once hoped that static analysis would remove most of the vulnerabilities of C, but that hasn't happened it seems.
I have a custom BSD that I use, it's not that large. It's like 20k lines. The problem is not the language, but the people. people suck at pointers and under/overruns. For instance, I have memory that is allocated that starts with the address and the length, so there's overhead but you can never overun your memory.
@MaartenBodewes no, basically, it's just carefully designed.
mostly, it's writing to registers.
and timers.
there's not a lot of actual logic
like this:
#define JSSP01 JSSP01
extern volatile uint32_t JSSP01 __attribute__(address(0xBF801538)));
typedef struct {
uint32_t JSSP01bits:4;
} __JSSP01bits_t;
I spend a lot of time just setting bits :/
There's probably better ways to tackle the problem of coding platforms; however, the abstraction required is pretty hard. Generally, the hardware guys do the bring up just because we know what/how it works.
18:05
Wow, such unreadable code. I guess it becomes more logical when you see more of it.
I've spend a lot of time just setting bits too. Where is the u32.setBit(loc), right?
19:06
And, @fgrieu uses the hash hammer.
19:38
I've been asked to write small things in C where I just did the development in another language and manually translated the code to C when I was done.
I made the mistake of telling someone I did that once, though. It automatically disqualified my code in their eyes.
As long as a language isn't dynamically typed it's fairly easy to mentally map small amounts of code in any language to unoptimized assembly. It's not hard to write code high level code that produces the same output as a given piece of assembly. (Functionally compatible code, that is. Not so much code that does the same task the same way. Or anything that needs to care about which registers get used.)
Wouldn't most higher level languages be written in C? The only runtime I ever wrote was a Java coprocessor, and that was in C and then we targeted it to VHDL. That was ages ago. You probably could have Java create a byte code interpreter.
I could write Java that emits machine code. It would be a pain though because I'd then have to reimplement something that's already been implemented in C many times though. There doesn't inherently need to be source-level dependency on C in higher level languages.
You could write a Java compiler in C# which converts programs to webasm instead of Java's traditional byte code.
19:55
just shows that I don't damn little about computer science in general
"Python as a language is just a set of rules (like syntax rules, or descriptions of standard functionality)" That's true for languages in general. There is also nothing stopping someone from writing a C compiler in Python.
@MaartenBodewes ... so Rust? :p
And it (this hypothetical compiler) could emit binaries that run at the same speed or faster than something like GCC. The compiler might be slow because it runs in an Python environment, but the output need not inherent the compiler implementation's Python-ness.
hi :) if i have two scalars for a ristretto curve (integer under mod group order) generated by taking the sha512 hash of some data and i add them (under mod group order), is that operation collision resistant? is there anywhere i can find things to read on that?
@Restioson So you independently hash two values into a group and then use the group operation to combine them?
20:05
Yes
I think
let me check actually
i explained it wrong and you are correct. i compute (sha512(x) mod L) * P where P is the basepoint of the ristretto curve and apply the group operation * of that to (sha512(y) mod L) * P
i have some short proof-of-concept code if that would help
@FutureSecurity funnily enough most languages have LLVM bindings so you can emit code that is as efficient as clang's somewhat easily
@Restioson the "* P" is scalar multiplication with the basepoint?
Then this should have the same security properties as SHA-512(x) XOR SHA-512(y)
(which has seen more coverage on our site)
ok i will google that
sry i am new to cryptography
@Restioson np
20:09
But won't people argue that LLVM is written in C, so that means mutter mumble mutter?
the basic end goal is to get an unordered multiset hash and i thought one could use the ristretto curve + some hash function to do that
just to use it to compare datasets
actually I was wrong on my XOR claim, because generic group operations don't suffer from self-inversion
... self-inversion?
where you have a cycle introduced in the curve?
that shouldnt happen on ristretto as far as i can tell because the basepoint =/= the point of inflection and it is a cyclic group
no, I mean SHA512(x) XOR SHA512(x) clearly is bad but I don't think it's bad if + is used instead of XOR
o
i was still looking up that
i read a paper related to this, let me find it
so i was trying to adapt that to use elliptic curves
20:15
@Restioson I think this addition result should carry over to the ECC group(s)
hmm
maybe should i open a question? just to get more opinions on it?
@FutureSecurity well, in the end you'll have a hard time finding an OS that is not at least partially written in C so you can always argue that some part of your stack is using C :p
Redox is mostly rust iirc
im rlly unsure of this considering that i basically came up with the implementation after reading a few random papers
@Restioson yes, but don't forget to link the paper
i won't
20:18
@Restioson I think Windows these days is also at least partially Rust
really?
lemme find the source
I think people think that C is faster than any "programming language written in C" because they see it as a nesting doll situation. Like if you write something in assembly then it's supposed to be as fast as you can possibly get. Then if you write something in C then it will inherently be at least slow as the same thing implemented in assembler.
And if you write a program written in a language written in C then it inherently has to be even more inefficient because you're nesting assembly in C in Python.
actually I'm wrong, they're looking into using Rust but haven't shipped components written in Rust yet
@FutureSecurity this is true for interpreters but not for compilers
the thing with asm is that you can get rlly close to the metal obviously but 99% of us don't know how to use the metal efficiently
and like, the real down low stuff like exactly which instructions are most efficient in which cases
20:25
People don't understand that there is a difference between interpreters and compilers though. It's hard to argue with someone who thinks C is the fastest thing short of assembly because of that nesting logic. If you give them a counterexample then they'll latch onto any little piece of the stack that uses C. So they would argue that your LLVM-based compiler is only produces efficient binary code because C is fast.
If you give them a counterexample that uses no C whatsoever, a project bootstrapped without having ever having used any C-based dependencies in its entire history, then they're going to think "Well, that still proves my point because it's based on ASM instead of C so of course it's just as good."
@FutureSecurity do you know any other languages besides C that have a "volatile" type keyword? I have registers change all of the time in hardware.
@bdegnan Rust
I'm not aware of popular examples that support arbitrary volatile memory accesses. Lots of languages have a more restricted form that allows volatile access to compiler-managed variable.
You could make arbitrary volatile and fenced memory accesses in non-standard Java though using Sun's "Unsafe" class.
Compilers could do something like that for any other language
Got to go for a bit
 
2 hours later…
22:10
"I think people think that C is faster than any "programming language written in C" because they see it as a nesting doll situation. Like if you write something in assembly then it's supposed to be as fast as you can possibly get. Then if you write something in C then it will inherently be at least slow as the same thing implemented in assembler."
@FutureSecurity Above is not correct per se though. There are plenty of examples where a JIT beats stuff written in low level C++, for instance. Cryptography not being one of them, mind you.
yeah, a JIT can specialize more than compilers can
and if that makes a difference
@SEJPM Yeah, but the JVM is written in C. Well sure, parts of it is probably even written using assembly. However, the trick is to make the amount of code that is vulnerable as small as can be. The footprint for errors is much smaller with a JVM.
That said, there have been very weird loopholes when it comes to MT, reflection and native access
And things like mutable class fields that are really dangerous. Java should not have allowed those to exist.
Configurable XML parsers and TLS libraries are horrid too. One config to rule them all!
There was a lot of arguments in the C++ community ridiculing the insecurity of Java because e.g. problems with the imaging library. Of course, that mainly depended on a native library written in .... guess what.
22:55
@SEJPM I mean, it's still trivial to find collisions
@Maeher huh?
they basically defined a hash function as H(x,y)=SHA512(x)*P + SHA512(y)*P. Trivially H(x,y)=H(y,x)
@Maeher ooh, yeah, I missed that.
@Maeher @Restioson this may be interesting for you
23:12
@kelalaka Yes. At least, I was conscious of what my close vote as duplicate would do. If it was not appropriate here, I want to know why.

« first day (3141 days earlier)      last day (1831 days later) »