Security Primitive Design with Nanoscale Devices: A Case Study with Resistive RAM