[GitHub] [mynewt-core] utzig commented on a change in pull request #2184: crypto/mbedtls: add hardware entropy config hooks

2020-02-25 Thread GitBox
utzig commented on a change in pull request #2184: crypto/mbedtls: add hardware 
entropy config hooks
URL: https://github.com/apache/mynewt-core/pull/2184#discussion_r384100903
 
 

 ##
 File path: hw/drivers/trng/src/mbed_entropy_alt.c
 ##
 @@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include 
+#include "mbedtls/config_mynewt.h"
 
 Review comment:
   Is this still needed? Maybe you could just use "os/mynewt.h" now?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] utzig commented on a change in pull request #2184: crypto/mbedtls: add hardware entropy config hooks

2020-02-25 Thread GitBox
utzig commented on a change in pull request #2184: crypto/mbedtls: add hardware 
entropy config hooks
URL: https://github.com/apache/mynewt-core/pull/2184#discussion_r383910115
 
 

 ##
 File path: hw/drivers/trng/src/mbed_entropy_alt.c
 ##
 @@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include 
+#include "mbedtls/config_mynewt.h"
+
+#ifdef MBEDTLS_ENTROPY_HARDWARE_ALT
 
 Review comment:
   I would avoid including `mbedtls/config_mynewt.h` and using instead `#if 
MYNEWT_VAL(MBEDTLS_ENTROPY_HARDWARE_ALT)` here.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] utzig commented on a change in pull request #2184: crypto/mbedtls: add hardware entropy config hooks

2020-02-25 Thread GitBox
utzig commented on a change in pull request #2184: crypto/mbedtls: add hardware 
entropy config hooks
URL: https://github.com/apache/mynewt-core/pull/2184#discussion_r383899100
 
 

 ##
 File path: hw/drivers/trng/src/mbed_entropy_alt.c
 ##
 @@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include 
+#include "mbedtls/config_mynewt.h"
+
+#ifdef MBEDTLS_ENTROPY_HARDWARE_ALT
+int
+mbedtls_hardware_poll(void *data, unsigned char *output, size_t len, size_t 
*olen)
+{
+struct trng_dev *trng;
+int ret;
+
+trng = (struct trng_dev *)os_dev_lookup("trng");
 
 Review comment:
   Maybe addding
   ```
   if (trng == NULL) {
   return -1;
   }
   ```
   What do you think?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] utzig commented on a change in pull request #2184: crypto/mbedtls: add hardware entropy config hooks

2020-02-25 Thread GitBox
utzig commented on a change in pull request #2184: crypto/mbedtls: add hardware 
entropy config hooks
URL: https://github.com/apache/mynewt-core/pull/2184#discussion_r383898430
 
 

 ##
 File path: hw/drivers/trng/src/mbed_entropy_alt.c
 ##
 @@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include 
+#include "mbedtls/config_mynewt.h"
+
+#ifdef MBEDTLS_ENTROPY_HARDWARE_ALT
+int
+mbedtls_hardware_poll(void *data, unsigned char *output, size_t len, size_t 
*olen)
+{
+struct trng_dev *trng;
+int ret;
+
+trng = (struct trng_dev *)os_dev_lookup("trng");
+ret = trng_read(trng, output, len);
+if (ret == len) {
+*olen = len;
+} else {
+*olen = 0;
+}
 
 Review comment:
   `trng_read` does not return errors, so this testing could be eliminated by 
simply doing `*olen = trng_read(trng, output, len);`


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services